1. Center
' Colum ' Print (Name.center,'*')
View Code
Fill in the middle of the content, the effect is ******colum*******
2.Count
Calculate the number of input parameters
' Colum ' Print (Name.count ('u'))
3.decode Decoding encode encoding
4.Expandtabs
Change the tab to a space, or you can use \ t to replace a space
' He is 2*tab'print(Name.expandtabs ())
He is 2*tab
5.Find Index
Find the parameters and return to the location. Find return failure also has a value of -1, index lookup failed to return an error
' He is 2*tab'print(name.find ('2'7
Print (Name.find (' 3 '))
-1
Print (Name.index (' 3 '))
Valueerror:substring not found
6.Join
Connection string
' He is 2*tab'print("_". Join (name)) H_e_ _i_s_ _ _2_*_t_a_b
7.partition
Split the content into three parts, with the parameter as the middle
' He is 2*tab'print(name.partition ('2')) (' He is\t\t'2'*tab' )
8.replace
Replace
' He is 2*tab'print(name.replace ('2','3 'is 3*tab
9.split
Split return list, default space split
' He is 2*tab'print(name.split ('*')) [' He is\t\t2'tab']
10.strip
The default is to remove the space at both ends of the line, the parameter is remove content
' 22112 He is 2*tab 2'print(Name.strip ('2')) 2*tab 21
Python String function Learning