1, str. Replace(word0,word1) # #用word1替换str中所有的word0
>>> ' Tea for too '. Replace (' too ', ' both ') output: ' Tea for both '
2, str. Lower() # #字符串str中的字母all converted to lowercase
STR. Upper() # #字符串str中的字母convert all to uppercase
Str. Capitalize() # #字符串str中的first letter converted to uppercase
>>> ' df Dfs ds '. Upper () ' DF Dfs ds ' >>> ' sdf SF omp dfs '. Lower () ' SDF SF omp dfs '
>>> ' df Dfs ds '. Capitalize ()
' Df DFS ds '
3. Str. Split(Sep) # # to divide str by Sep by default when Sep is sliced according to Whilespace (Space, tab, newline, return, FormFeed)
>>> ' df Dfs ds '. Split () [' DF ', ' Dfs ', ' ds ']>>> ' Df,dfs,ds '. Split (', ') [' DF ', ' Dfs ', ' DS ']
----< continued >---------
Using Regular expression to pass the distribution processing
>>> Import re
Re.findall (R ' \bf[a-z]* ', ' which foot or hand fell fastest ')
Output: [' foot ', ' fell ', ' fastest ']
re.sub (R ' (\b[a-z]+) \1 ', R ' \1 ', ' Cat in the The Hat ')
Output: ' Cat in the Hat '
"Python" String functions