Python string built-in handler function

Source: Internet
Author: User

Capitalize (): Capitalize the 1th character in a string

Center (width): Returns a string with a length of at least width and centers the contents of the original string

Count (Str,beg=0,end=len (String)): Returns the number of occurrences of STR within a string, which can be specified using the start index (beg) and end index (end)

Decode (encoding= "UTF-8", errors= ' strict '): Decodes string in encoding specified encoding format

Encode (encoding= ' UTF-8 ', errors= ' strict '): Encode string in encoding specified encoding format

EndsWith (Obj,beg=0,end=len (String)) B,e: Checks whether the string ends with obj, returns True if it is, or false to specify the scope of the search with the start index (beg) and end index (end)

Expandtabs (tabsize=8): Convert the tab character in Str to a space, the default number of spaces is tabsize 8.
Find (Str,beg=0,end=len (String)): detects if STR is contained in a string, can specify the scope of the search using the start index (beg) and end index (end), returns the index value if found, returns 1 if not found

Index (Str,beg=0,end=len (String)): Similar to find, but if Str is not in string, an exception is reported.

Isalnum (): Returns True if one character is found and all characters are letters or numbers, otherwise false

Isalpha (): Returns True if one character is found and all characters are letters, otherwise false

Isdecimal (): Returns True if it can be interpreted as a decimal number, otherwise false

IsDigit (): Returns True if it can be interpreted as a number, otherwise false

Islower (): Returns True if the characters in the string are lowercase, otherwise false

IsNumeric (): Returns True if only numeric characters are included, otherwise false

Isspace (): Returns True if the string is a space, otherwise false

Istitle (): Returns True if the string is heading, False otherwise

Isupper (): Returns True if all characters in the string are uppercase, otherwise false

Ljust (): Returns the left alignment of an original string and fills the new string with a space of length width

Lower (): Xuan change all uppercase characters to lowercase

Lstrip (): Truncates the left space of a string

Replace (Str1,str2,num=count (STR1)): Replaces str1 in string with str2,num specifies the maximum number of substitutions

RFind (Str,beg=0,end=len (String)): Similar to find, but looks from the right

Rindex (Str,beg=0,eng=len (String)): similar to index, but looks from the right

Rjust (width): Returns the right alignment of an original string and fills the new string with a space of length width

Rpartition (str) E: Class is intended for the partition () function, but finds it from the right

Rstrip (): Remove space at the end of a string string

Splite (str= ", Num=count (str)): Slices A string with the Str delimiter, or only the NUM substring if NUM has the specified value

Splitlines (Num=count (' \ n ')): Returns a list containing rows as elements, separated by rows, and slices only num rows if num is specified

StartsWith (Obj,beg=0,end=len (String)): Checks whether the string starts with obj, returns True if it is, or false, and can specify the search scope with the start index (beg) and end index (end)

Strip ([obj]): Executes Lstrip () and Rstrip () on string

Swapcase (): Flips the case in a string

Title (): Headings The string, that is, all words start with uppercase, and the remaining letters are lowercase

Translate (str,del= ""): Converts a string character according to the table given by STR and the character to be filtered into the Del parameter

Upper (): Convert lowercase letters in string to uppercase

Zfill (width): Returns a string of length width, the original string is right-aligned, the front padding 0

Python string built-in handler function

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.