Capitalize () |
Change the first character of the string to uppercase. |
Casefold () |
Change all characters of the entire string to lowercase letters. |
Center (width) |
Center the string and fill it with spaces to the new string with the length and width. |
Count (sub [, start [, end]) |
Returns the number of times that sub appears in the string. the start and end parameters indicate the range. Optional. |
Encode (encoding = 'utf-8', errors = 'strict ') |
Encode the string in the encoding format specified by encoding. |
Endswith (sub [, start [, end]) |
Check whether the string ends with a sub-string. If yes, return True; otherwise, return False. The start and end parameters are optional. |
Expandtabs ([tabsize = 8]) |
Convert the tab character (\ t) in the string to a space. If no parameter is specified, the default number of spaces is tabsize = 8. |
Find (sub [, start [, end]) |
Checks whether sub is contained in a string. If yes, the index value is returned. Otherwise, the-1, start, and end parameters are returned, indicating the range. Optional. |
Index (sub [, start [, end]) |
Similar to the find method, however, if sub is not in string, an exception is generated. |
Isalnum () |
Returns True if the string contains at least one character and all characters are letters or numbers. Otherwise, returns False. |
Isalpha () |
Returns True if the string contains at least one character and all characters are letters; otherwise, returns False. |
Isdecimal () |
Returns True if the string contains only decimal digits; otherwise, returns False. |
Isdigit () |
Returns True if the string contains only numbers; otherwise, returns False. |
Islower () |
If the string contains at least one case-sensitive character and all these characters are in lower case, True is returned; otherwise, False is returned. |
Isnumeric () |
If the string contains only numeric characters, True is returned; otherwise, False is returned. |
Isspace () |
If the string contains only spaces, True is returned; otherwise, False is returned. |
Istitle () |
True is returned if the string is title (all words start with uppercase and all other letters are lowercase). Otherwise, False is returned. |
Isupper () |
If the string contains at least one case-sensitive character and all these characters are uppercase, True is returned; otherwise, False is returned. |
Join (sub) |
Use a string as the separator and insert it into all the characters of sub. |
Ljust (width) |
Returns a left-aligned string and fills it with spaces to a new string with a width length. |
Lower () |
All uppercase characters in the conversion string are lowercase. |
Lstrip () |
Removes all spaces on the left of the string. |
Partition (sub) |
Locate the sub-string and divide the string into three tuples (pre_sub, sub, fol_sub). If the sub is not included in the string, return ('original string ','','') |
Replace (old, new [, count]) |
Replace the old substring in the string with the new substring. If count is specified, it cannot exceed count. |
Rfind (sub [, start [, end]) |
It is similar to the find () method, but it is searched from the right. |
Rindex (sub [, start [, end]) |
It is similar to the index () method, but starts from the right side. |
Must ust (width) |
Returns a right-aligned string and fills it with spaces to a new string with a width length. |
Rpartition (sub) |
Similar to the partition () method, but the query starts from the right side. |
Rstrip () |
Removes spaces at the end of a string. |
Split (sep = None, maxsplit =-1) |
By default, the non-parameter slice string is separated by spaces. If the maxsplit parameter is set, only the maxsplit substrings are separated and the list of substrings after the slice is returned. |
Splitlines ([keepends]) |
Separated by '\ n', a list containing all rows as elements is returned. If the keepends parameter is specified, the former keepends row is returned. |
Startswith (prefix [, start [, end]) |
Check whether the string starts with prefix. If yes, True is returned. Otherwise, False is returned. Range check can be specified for the start and end parameters. Optional. |
Strip ([chars]) |
Delete all leading and trailing spaces of a string. The chars parameter can be used to customize the characters to be deleted. Optional. |
Swapcase () |
Flip the case in the string. |
Title () |
Returns a title string (all words start with uppercase and all other letters are lowercase. |
Translate (table) |
Convert characters in a string according to table rules (which can be customized by str. maketrans ('A', 'B. |
Upper () |
All lowercase characters in the conversion string are in uppercase. |
Zfill (width) |
Returns a string with the length of width. The original string is right aligned and the front side is filled with 0. |