capitalize() |
The first letter is capitalized and other letters are lowercased (only valid for strings starting with a letter) |
lower() |
String letters are converted to lowercase (affects letters anywhere in the string) |
upper() |
String letters are converted to uppercase (affects letters anywhere in the string) |
swapcase() |
Uppercase to lowercase Lowercase to uppercase (valid for all alphabetic characters in the string) |
zfill(x) |
Define the length (x) for the string If the missing position is not satisfied, fill it with 0 (0 is added in front of the string) |
startswith(val) |
Determine whether the beginning is val and return a Boolean value |
endswith(val) |
Determine whether the end is val and return a Boolean value |
find(val) |
Returns the index of val in the current string or -1 if the current string does not contain val |
index(val) |
Returns the index of val in the current string. If the current string does not contain val, the program will directly report an error |
strip(val) |
Strip all vals at the beginning and end of the string (spaces by default) aabbaa.strip("a")=bb |
lstrip(val) |
Remove all val at the beginning of the string (the default is a space) aabbaa.strip("a")=bbaa |
rstrip(val) |
Remove all val at the end of the string (default is space) aabbaa.strip("a")=aabb |
replace(old,new,maxNu) |
old old (before replacement) new (after replacement) maxNu (the number that needs to be replaced is not filled in, the default is all) |
isspace() |
Determine whether the string consists of only spaces and return a Boolean value" ".isspace=>true '''.isspace=>false |
istitle() |
Determine whether it is the title "Hellow Word" "Hellow"=>true "Hellow Word"="false" |
isupper() |
Judging whether all letters in the string are all uppercase can have Chinese |
islower() |
Determine whether all letters in the string are all lowercase and can have Chinese characters |