Python string (str)

Source: Internet
Author: User

I. STR type

The content of the "" "" "" "is a string.

Strings are immutable data types, and each operation returns a new string regardless of what you do

Index starting from 0, using [] can get to each character, can also be inverted (str[])

Slice

str[:]

Gu Tou regardless of the tail

No step can be cut from left to right

A negative length can be cut from right to left

Related Operations on strings

. Format {}. Format () {} can also put the index of a string

S.title () capitalize the first letter of each word

. Upper () (converted to uppercase)

. Lower (). Casefold (Convert to lowercase)

. Capitalize () (to capitalize the first letter of one character)

. Swapcase () (case-sensitive interchange)

. Remove () (delete)

. Stript () Remove the left and right spaces

. replace (old,new) replaces xxx with XXX (can also be added in the following times)

. Split () cut. Returns the list with how long the knife is going to lose.

. StartsWith () Decide whether to start with XXX

. EndsWith () Decide whether to end with

Len () string length (Python's built-in function)

. Find () finds the position where xxx appears in the string, finds only the first occurrence, and returns No 1

. Count () find the position where the character appears in the string

. Index () Look for the position where the xxx string appears, when the character does not present an error

Whether the. IsDigit () is made up of integers

Whether the. Isalpha () is composed of letters

Whether the. Isalnum () is made up of numbers and letters

Python string (str)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.