python字符串的常见处理方法

  python字符串的常见处理方法

方法 使用说明 方法 使用说明
string[start:end:step] 字符串的切片 string.replace 字符串的替换
string.split 字符串的分割 sep.jojin   将可迭代对象按sep分割符拼接为字符串
string.strip 删除首尾空白 string.lstrip 删除字符串左边空白
string.rstrip 删除字符串右边的空白 string.count 对字符串的字串计数
string.index 返回子串首次出现的位置 string.find

返回字串首次出现的位置(找不到返回-1)

string.startwith 字符串是否以什么开头 string.endwith 字符串是否以什么结尾

猜你喜欢

转载自www.cnblogs.com/tinglele527/p/11686548.html
今日推荐