Capitalize () |
Change the first character of a string to uppercase |
Casefold () |
Change all characters of the entire string to lowercase |
Center (width) |
Centers the string and fills the new string with a space of length width |
Count (Sub[,start[,end]]) |
Returns the number of occurrences of a sub within a string, with the start and end parameters representing the range, optional. |
Encode (encoding= ' utf-8 ', errors= ' strict ') |
Encodes a string in the encoding format specified by encoding. |
EndsWith (Sub[,start[,end]) |
Checks whether the string ends with a sub substring, or returns False if True. The start and end parameters represent ranges and are optional. |
Expandtabs ([tabsize=8]) |
Converts the tab symbol (\ t) in a string to a space, such as not specifying a parameter, and the default number of spaces is tabsize=8. |
Find (Sub[,start[,end]) |
Detects if the sub is contained in a string, returns the index value if any, otherwise returns the -1,start and end parameters to indicate the range, optional. |
Index (Sub[,start[,end]]) |
Same as the Find method, but an exception occurs if the sub is not in a string. |
Isalnum () |
Returns True if the string has at least one character and all characters are letters or numbers, otherwise false is returned. |
Isalpha () |
Returns True if the string has at least one character and all characters are letters, otherwise false is returned. |
Isdecimal () |
Returns True if the string contains only decimal digits, otherwise false. |
IsDigit () |
Returns True if the string contains only a number, otherwise false. |
Islower () |
Returns True if the string contains at least one case-sensitive character, and the characters are lowercase, otherwise false. |
IsNumeric () |
Returns True if the string contains only numeric characters, otherwise false is returned. |
Isspace () |
Returns True if the string contains only spaces, otherwise false is returned. |
Istitle () |
Returns True if the string is a caption (all words start with uppercase and the remaining letters are lowercase), otherwise false is returned. |
Isupper () |
Returns True if the string contains at least one case-sensitive character, and the characters are uppercase, otherwise false. |
Join (sub) |
Inserts a string as a delimiter between all the characters in a sub. |
Ljust (width) |
Returns a left-aligned string and fills the new string with a width of length with a space. |
Lower () |
Converts all uppercase characters in a string to lowercase. |
Lstrip () |
Remove all spaces to the left of the string |
Partition (sub) |
Locate the substring sub, divide the string into a 3-tuple (pre_sub,sub,fol_sub), and return if the string does not contain a sub (' Original string ', ' ', ') |
Replace (Old,new[,count]) |
Replaces the old substring in the string with the new substring and, if count specifies, does not exceed count times. |
RFind (Sub[,start[,end]) |
Similar to the Find () method, it is just looking from the right. |
Rindex (Sub[,start[,end]) |
Similar to the index () method, but starting from the right. |
Rjust (width) |
Returns a right-aligned string and fills the new string with a width of length with a space. |
Rpartition (sub) |
Similar to the partition () method, it is just looking from the right. |
Rstrip () |
Removes a space at the end of a string. |
Split (Sep=none, Maxsplit=-1) |
The default is a space-delimited slice string without parameters, and if the Maxsplit parameter has a setting, only the Maxsplit substring is separated, returning the list of sub-string concatenation after the slice. |
Splitlines ([keepends]) |
Returns a list containing the rows as elements, separated by ' \ n ', and returns the first Keepends row if the Keepends parameter is specified. |
StartsWith (Prefix[,start[,end]) |
Checks whether the string starts with prefix, returns True, or false. The start and end parameters allow you to specify a range check, optional. |
Strip ([chars]) |
Remove all whitespace from the front and back of the string, the chars parameter can be customized to remove the character, optional. |
Swapcase () |
Flips the case in the string. |
Title () |
Returns a string that is titled (all words are started in uppercase and the remaining letters are lowercase). |
Translate (table) |
The characters in the string are converted according to the table's rules (which can be customized by Str.maketrans (' A ', ' B '). |
Upper () |
Converts all lowercase characters in a string to uppercase. |
Zfill (width) |
Returns a string of length width, the original string is right-aligned, and the front is filled with 0. |