Method |
Description |
String.capitalize () |
Capitalize the first character of a string |
String.center (width) |
Returns the center of the original string and fills the new string with a space of length width |
String.count (str, beg=0, End=len (String)) |
Returns the number of occurrences of STR in a string, if beg or end specifies that the number of STR occurrences in the specified range is returned |
String.decode (encoding= ' UTF-8 ', errors= ' strict ') |
Decodes a string in the encoded format specified by encoding, if an error defaults to a ValueError exception unless errors specifies ' ignore ' or ' replace ' |
String.encode (encoding= ' UTF-8 ', errors= ' strict ') |
Encodes a string in the encoding format specified by encoding, if an error defaults to a ValueError exception unless errors specifies ' ignore ' or ' replace ' |
String.endswith (obj, beg=0, End=len (String)) |
Checks whether the string ends with obj, or returns False if beg or end specifies whether to end with obj in the specified range, or True if it is. |
String.expandtabs (tabsize=8) |
Turns the tab symbol in string strings to a space, and the default number of spaces for the tab symbol is 8. |
String.find (str, beg=0, End=len (String)) |
Detects if STR is contained in a string, and if beg and end specify a range, the check is contained within the specified range, and returns 1 if the index value is returned. |
String.index (str, beg=0, End=len (String)) |
Just like the Find () method, only if STR does not report an exception in string. |
String.isalnum () |
If the string has at least one character and all characters are letters or numbers, return Return True, otherwise False |
String.isalpha () |
Returns True if the string has at least one character and all characters are letters. otherwise returns False |
String.isdecimal () |
Returns True if the string contains only a decimal number, otherwise False. |
String.isdigit () |
Returns True if the string contains only a number, otherwise False. |
String.islower () |
Returns True if the string contains at least one case-sensitive character, and all of these (case-sensitive) characters are lowercase, otherwise False |
String.isnumeric () |
Returns True if the string contains only numeric characters, otherwise False |
String.isspace () |
Returns True if the string contains only spaces, otherwise False is returned. |
String.istitle () |
Returns True if string is heading (see Title ()), otherwise False |
String.isupper () |
Returns True if the string contains at least one case-sensitive character, and all of these (case-sensitive) characters are uppercase, otherwise False |
String.Join (seq) |
Merges all the elements in the SEQ (the string representation) into a new string, using string as a delimiter |
String.ljust (width) |
Returns the left alignment of an original string and fills the new string with the width of length with a space |
String.Lower () |
Converts all uppercase characters in a string to lowercase. |
String.lstrip () |
Truncate the left space of a string |
String.maketrans (Intab, Outtab]) |
The Maketrans () method is used to create a conversion table of character mappings, for the simplest invocation of two parameters, the first argument is a string that represents the character that needs to be converted, and the second argument is the target of the string representation of the transformation. |
Max (str) |
Returns the largest letter in the string str . |
Min (str) |
Returns the smallest letter in the string str . |
String.partition (str) |
A bit like the combination of find () and split (), from the first position where Str appears, divide the string into a 3-element tuple (STRING_PRE_STR,STR,STRING_POST_STR), if string STR is not included in the STRING_PRE_STR = = string. |
String.Replace (str1, str2, Num=string.count (STR1)) |
Replace the str1 in string with the str2, if NUM is specified, the replacement is no more than num times. |
String.rfind (str, Beg=0,end=len (String)) |
Similar to the Find () function, it is just looking from the right. |
String.rindex (str, Beg=0,end=len (String)) |
Similar to index (), but starting from the right. |
String.rjust (width) |
Returns the right alignment of the original string and fills the new string with the width of the length with a space |
String.rpartition (str) |
Similar to the partition () function, it is just looking from the right. |
String.rstrip () |
Removes a space at the end of a string string. |
String.Split (str= "", Num=string.count (str)) |
Slice string with a delimiter of STR, if NUM has a specified value, only the NUM substring is delimited |
String.splitlines (Num=string.count (' \ n ')) |
Returns a list that contains rows as elements, separated by rows, and if num specifies that only num rows are sliced. |
String.startswith (obj, Beg=0,end=len (string)) |
Checks whether the string starts with obj, returns True, or False. If beg and end specify a value, the check is within the specified range. |
String.strip ([obj]) |
Execute Lstrip () and Rstrip () on string |
String.swapcase () |
Flip the case in a string |
String.title () |
A string that returns "header", meaning that all words start with uppercase and the remaining letters are lowercase (see istitle ()) |
String.translate (str, del= "") |
Converts a string of characters according to the table given by STR, which contains 256 characters, The characters to filter out are placed in the Del parameter |
String.upper () |
Convert lowercase letters in string to uppercase |
String.zfill (width) |
Returns a string of length width, the original string is right-aligned, and the front padding is 0 |
String.isdecimal () |
The Isdecimal () method checks whether a string contains only decimal characters. This method exists only in Unicode objects. |