= name " LIHUA " # name.capitalize () capitalized # name.count ( "a") statistics a number of characters # whether name.endswith ( "ua") determine string ends UA name = " My \ iS Lihua tname " # name.expandtabs (TabSize = 30) the tab into spaces 30 # name.find (" i ") for the characters, returns the index, such as LiHua returns 1 (the default is to look from left to right) name [name.find ( " name " ):] for sectioning string name.rfind ( " i " ) from the right to find the first occurrence of the character i, and returns its index # name = "My {} and the _name _year} { " name.format (the _name = ' Lihua ' ,_year=23)_year=23 name.format_map( { ' name ' : ' Lihua ' , ' year ' : ' 12 is ' }) writing dictionary, but as a result, and the # name.isalnum () determines whether the Arabic characters (letters plus numbers), and returns It is true or false # name.isalpha () to determine whether the plain English characters # name.isdecimal () to determine whether the decimal # name.isdigit () to determine whether similar digital and name.isnumeric () # name. isidentfier () to determine whether a valid identifier (variable name) (or the underscore character that is led by legitimate) (less) # name.islower () to determine whether lowercase name.isupper () to determine whether capital # name.isspace () determine whether a space # name.istitle () to determine whether the first character of each word capitalized, except for the first letter, other letters to uppercase if it returns false #name.isprintable () to determine whether to print (less, TTY File \ Drive File) # swapcase () will be converted to lowercase characters uppercase, lowercase to uppercase # title () The first character of each word capitalized string # the Join ( ) Print ( ' + ' .join ([ ' 1 ' , ' 2 ' , ' 3 ' ])) the result is 1 + 2 + 3 i.e., takes out a number from a list, it adds the specified character ' + ' Note It is ' string ' .join () # split () is divided into a list Print ( ' . 1 + 2 + +. 4. 3 ' .split ( ' + ' )) the ' +' As a delimiter, and is converted to a segmented list, a result [ ' . 1 ' , ' 2 ' , ' . 3 ' , ' . 4 ' The splitlines () similar usage # ljust () Print (name.ljust ( 50, ' * ' )) print 50 characters, if the number of characters is not enough, the string on the left, on the right padding character # rjust () Print (name.ljust (50, ' * ' )) Print 50 character, if the number of characters is not enough, the string on the far right, filled with characters on the left - ! Note above ljust rjust the l and r is the position corresponding to the target string left or right # Center () # name .center (50, "-") to print 50 characters, if the number of characters is not enough, then use "-" fill and character centered #zfill (50) are filled with zeros # Lower () Print ( ' Lihua ' .lower) # Upper () Print ( ' Luhua ' .upper) # lstrip () to the left of the space character and a carriage return rstrip () to the right characters and spaces Enter strip () to remove the left edge of a character space, carriage Print ( ' Lihua \ n- ' .strip) (custom escape code) # P = str.maketrans ( "abcdef", "123456") is defined as the conversion abcdef 123456 (the number must be uniform) Print ( " Lihua " .translate (P)) is converted into other character string by the corresponding conversion relationships # replace () replace Print ( ' Lihua' .Replace ( ' l ' , ' L ' , 1 )) of the lihua l of replacing uppercase L, if more, 1 represents only one alternative, this parameter can not write