WordS= "Aleawusir"
S1=s.capitalize () #首字母大写
S2=s.upper () #全部变成大写
S3=s.lower () #全部变成小写
S4=s.swapcase () #大小写翻转
S5=s.title () #特殊字符或数字隔开 (capitalize the first letter of each separated word)
# s6=s.center (parameters, padding) #居中, default blank padding
Len (s) #判断长度
S7=s.startswith ("Al") #判断以什么为开头, the value returned is True,false
S71=s.startswith ("E", 2,5) #从2开始, ends at 5
S72=s.endswith ("W", 2,5) #判断以什么结束, the value returned is True,false
S8=s.find ("Z") #通过元素找索引 (subscript), cannot find return-1
S82=s.index ("a") #通过元素找索引 (subscript), unable to find an error
S9=s.strip ("element") #删空格 (front and rear), Rstrip (right), Lstrip (left)
S10=s.count ("A", 0,5) #查元素的个数
z= "SDSDS;DSDSD;SDSD;DSDSD"
L=z.split (";") #分割文本 (default space) returns the list str→list
Format ({}) #按照位置依次输出 the contents of a placeholder. Formatted output
S11=s.replace ("A", "B", 2) # (old text, new text, number of times) Replace text
Isalnum () Determines whether a string consists of letters or numbers
The Isalpha () string consists only of letters
The IsDigit () string consists only of numbers
msg= "" "
I am: {name}
How old am I: {age}
I am very handsome: {Henshuai}
"" " . Format (name =" Shong ", age=19,henshuai=" true ")
Print (msg)
msg= "" "
I'm l:{0}
How old am I: {1}
I am very handsome: {2}
"" " . Format (" Shong "," True ")
Print (msg)
msg= "" "
I am: {}
How old am I: {}
I am very handsome: {}
"" " . Format (" Shong "," Trer ")
Print (msg)
3rd Day of Python Learning