字符串经常用的

isdigit()#表示字符串是不是数字

print('123'.isdigit())

replace()#替换字符串中的字符

print('afdsafsdaffff'.replace('a','c',1))

find()#查找字符串中的索引(就是第几个)

print('sdfsdfsdf'.find('s'))

strip()#去掉字符串中的空格和换行

print('
jkjlfs	   '.strip())

center()#以字符串为中心向两边填充

print('center'.center(40,'-'))

split()#以什么字符为标准变成列表

print('1,2,3,4,5'.split(','))

join()#把列表变成字符串

print(','.join(['1','2','3']))
原文地址:https://www.cnblogs.com/hunterYi/p/9807388.html