S.strip (chars) s.find (x,start,end) s.index (x.start,end)#see above;S.format ()#see above;S.partition (x)#see above;S.replace (X,y,n)#replace x with Y, optional n means maximum substitution n times;S.split (X,n)#divide up to n times, S.rsplit () splits from the right;S.splitlines (f)#returns a list that is split at the newline character and strips the newline character (unless F is true);S.count (X,start,end)#CountS.join (seq)#returns the result that each item of SEQ is concatenated with S, and s can be empty;S.capitalize ()#capitalize the first letter of the string;S.lower ()#changes the character in s to lowercase;S.upper ()#returns the capitalized version;S.title ()#capitalize the first letter of each word;S.swapcase ()#make uppercase lowercase, lowercase to uppercase;S.islower ()#returns True if S has at least one lowercase character and all lowercase characters are lowercase;S.isupper ()#returns True if S has at least one uppercase character and all uppercase characters are uppercase;S.istitle ()#returns True if S is a non-empty first-letter uppercase string;S.zfill (W)#returns a copy of S, if shorter than W, from the beginning with 0 supplement, so that the length and W;S.center (Width,char)#returns a string with the width of the center length of s, or padding with an optional argument char or a space if one is available, such as Width<len (s), which returns the entire S;S.ljust (Width,char)#Ibid., left-aligned;S.rjust (Width,char)#Ibid., right alignment;S.encode (Endoding,err)#returns a Bytes object that represents the string using the default encoding format or the specified encoding format, and handles errors based on the optional err parameter;S.endswith (X,start,end)#Returns true if End with X, otherwise false;S.startswith (X,start,end)#returns True if it starts with X;S.expandtabbs (size)#returns a copy of S, where the tabs are replaced with 8 or a specified number of spaces;S.isalnum ()#Determine whether it is all alphanumeric and not empty;S.isalpha ()#judge whether it is all letters and not empty;S.isdecimal ()#determines whether each character is a number with a base of 10 Unicode, and whether all characters are decimal charactersS.isdigit ()#determine if each character is an ASCII number;S.isidentifier ()#to determine if it is not emptyS.isnumeric ()#determines whether each character is a numeric Unicode character Fu Yingfi null;S.isprintable ()#determines whether each character is printable and not empty;S.isspace ()#determines whether each character is a blank character;S.maketrans ()#make a table of translation mappingsS.translate ()#translate input into output according to mapping table
View Code
A list of Python string manipulation functions