string = ' Kzx truthk '
String.capitalize () # Initial uppercase String.casefold () # Uppercase All lowercase string.center ("-") # output '-------------------- -KZX truthk----------------------' string.count (' Lex ') # Statistics on the number of Lex occurrences String.encode () # Encode the string into the bytes format string.endswith ("Li") # to determine if the string ends with Li "KZX\TTRUTHK". Expandtabs () # output ' Alex Li ', will \ T convert to a long space String.find (' R ') # Find A, Find returns its index, cannot find return-1 ' 9 '. IsDigit () # whether the integer string.isnumeric () string.isprintable ( ) String.isspace () String.istitle () string.isupper () "|". Join ([' kzx ', ' truth ', ' Ke ']) # result ' kzx|truth|ke ' msg = ' My name is ' {} ' and ' age ' {} ' Print (Msg.format ("Kzx", ' xx ')
Result: My name is KZX, and an age is XX
MG = "My name is {name}," and "Age was {age}" print (Mg.format (name= ' TRUTHK ', age= "xx") Result: My name is TRUTHK, and the IS XXMG.I Ndex (' n ') # Returns the index of the string where R is located mg.partition (' is ') # with ' is ' partition mg result (' My name ', ' is ', ' {name} ' and ' age ' {age} ')
A brief introduction to the Python3 string manipulation of the weak slag
If there is no, but also hope that you more advice
Python Foundation--string