Python string basic operation
1, judge is not a valid identifier Isidentifier
Name= "ABC" Print (Name.isidentifier ()) printing result true
2, the first letter capital capitalize
Name= ' abc ' Print (Name.capitalize ()) printed results ABC
3. Counting count
Name= ' abc ' Print (Name.count ("a")) printing Results 1
4, located in the center, with-to supplement the center
Name= ' abc ' Print (Name.center (50, "-")) printing results-----------------------ABC------------------------
5, judge whether to end with C EndsWith
Name= ' abc ' Print (Name.endswith ("C")) printing result true
6. Replace the carriage return with a blank expandtabs
Name = "A\TBC" Print (Name.expandtabs (tabsize=10)) results a BC
7. View a word Poute find
Name= ' abc ' Print (Name.find (' C ')) printing results 2
8. Lowercase lower characters
Print ("Xiedi". Lower ()) printing results Xiedi
9. Capitalize the characters Upper
Print ("Xiedi". Upper ()) Xiedi
Python string basic operation