str2 chuan str2.capitalize () Chuan upper 也可【学会查找所有方法 】 二 casefold() __大写全部变小写
str2 Chuan str2.casefold () chuan lower 也可三 center(width) __左右填充width长度的空格 字符串居中
str2 chuan str2.center(40) Chuan四 count(sub[,start[,end]]) __某字符出现的次数 可限定范围
str3 woainixiaochuanzi,shiwodebaobei str3.count( wo ) str3.count( wo ,1,24) 1五 endswith(sub[,start[,end]]) __是否以某字符结尾
str3 woainixiaochuanzi,shiwodebaobei str3.endswith( ei ) str3.endswith( obei ) True六 expandtabs([tabsize 8]) __将tab t 减去一个空格
str1 wwwwwwwwtwwwwwww str1.expandtabs() wwwwwwww wwwwwww print( aaaatbbb .expandtabs()) aaaa bbb print( aaaatbbbbbbtssssthh .expandtabs()) aaaa bbbbbb ssss hh print( aasdfgaeaadfgaDcDSaatbbbbbbtssssthh .expandtabs()) aasdfgaeaadfgaDcDSaa bbbbbb ssss hh
【解释】从第一个非空格开始 到【t】 有字符n个 n≤8 空格数就 8-n
如果n 8 就n-8 一直到n≤8 再空格数 8-n。
str1 I love chuanchuan str1.find( efc ) str1.find( ove ) 3八 find(sub[,start[,end]]) __检查sub是否出现在字符串内 返回值为所在位置 不在返回值为-1。可限定范围
str1 I love chuanchuan str1.find( efc ) str1.find( ove ) 3九 index(sub[,start[,end]]) __和find一样 不过如果sub不在则会返回异常。
str1 I love chuanchuan str1.index( efc ) Traceback (most recent call last): File pyshell#88 , line 1, in module str1.index( efc ) ValueError: substring not found
Traceback (most recent call last):
File pyshell#88 , line 1, in module
str1.index( efc )
ValueError: substring not found
str4 chuan str4.join( 12345 ) 1chuan2chuan3chuan4chuan5十三 ljust(width) 类比center(width)
str4 chuan str4.ljust(40) chuan str4.ljust(20) chuan十四 lstrip()
......剩下的自己查 自己看



