Python string manipulation

Source: Internet
Author: User

String Common operations

Judge

Variable. EndsWith ("trailing character"): determines the ending string.

Variable. Isalnum (): Determines whether it is a letter or a number.

Variable. Isalpha (): Determines whether it is an English character.

Variable. Isdecimal (): Determines whether the number is stored.

Variable. IsDigit (): Determines whether it is an integer.

Variable. Isidentifier (): Determines whether it is a valid variable name.

Variable. Islower (): Determines whether a string is capitalized.

Variable. IsNumeric (): Determines whether a string is a number.

Variable. Isspace (): Determines whether it is just a space.

Variable. Istitle (): Determines the first letter of each character to capitalize.

Variable. isprintable (): Determines whether the variable can be printed. (The tty,drive file is not printable)

Variable. Isupper (): Determines whether it is all uppercase.

The variable. StartsWith () method is used to check whether the string starts with the specified substring, or True if it is, otherwise returns False

Replace

Variable. Center (quantity, "character"): Specifies the print character, in the middle of the variable.

Variable. Format (character = ' character '): modifies the character in parentheses under the variable.

Variable/' character '. Join (Create List): Adds characters to the middle of each character.

Variable. Ljust (length, ' character '): The rightmost specified length is filled with characters.

Variable. Rjust (length, ' character '): the leftmost specified length is filled with characters.

Variable. Lstrip (): Remove the carriage return or space on the left.

Variable. Rstrip (): Remove the carriage return or space on the right.

Variable. Strip (): Remove the carriage return or space on either side.

variable. Replace (' Replace object ', ' replace value ', number): Replace string Default Select All.

Variable. Split (Specify delimiter): Default space split string a list output.

Variable. Splitlines (): Specifies a newline \ n to split.

Find

Variable. COUNT ("specified character"): Specifies the number of lookup characters.

Variable. Find ("string"): finds the position of the string, the leftmost value of precedence.

Variable. RFind ("string"): finds the position of the string, giving precedence to the rightmost value.

Transformation

Variable. Encode: Data type load conversion compilation.

Variable. Capitalize (): Capitalize the first letter of the variable.

Variable. Expandtabs (number of tabsize= spaces): The number of spaces to convert the tab.

Variable. lower (): lowercase becomes uppercase.

Variable. UPPER (): uppercase becomes lowercase.

Variable. Title (): Character starts with uppercase letters.

Variable. Translate (conversion variable): Import variable for conversion.

Variable = Str.maketrans (" converted value"," converted value"): The conversion of the string.

Variable. Swapcase (): Invert case to convert.

Note: variables. Zfill (range): The specified range is filled with a.

Len (): Returns the number of characters in parentheses, or the number of characters in a variable.

Python string manipulation

Related Article

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.