1、查找字符串:
#查找不存在的字符,报错
str.index(a)
#查找不存在的字符,返回-1
str.find(a)
2、是否包含指定字符串
in or not in
return bool
三、字符串的长度
len(a)
四、大小写转换
str.lower() #转小写
str.uppre() #转大写
str.capitalize() #首字母大写
str.swapcase() #大小写转换
五、剔除字符串符号
str.strip() #删除字符串两边的指定字符,无参数默认为空格
str.rstrip() #删除字符串右边的指定字符
str.lstrip() #删除字符串左边的指定字符
六、复制字符串
七、连接字符串
a+b
a.join(b) #迭代拼接
八、 字符串的切片
九、 字符串的分割
str.split(sep,maxsplit)
十、字符串的替换
str.replace(old,new,maxreplace)
十一、位置定位
a.center()
十二、字符串的统计
a.count()
十三、字符串测试判断函数
s.startswith(prefix[,start[,end]]) #是以prefix开头
s.endswith(prefix[,start[,end]]) #是以prefix结尾