python字符串Str方法
<1>find 检测 str 是否包含在 mystr中,如果是返回开始的索引值,否则返回-1 使用方法:str.find("xx",0,len(str)) <2>index 跟find()方法一样,只不过如果str不在 mystr中会报一个异常. 使用方法:str.index("xx") <3>count 返回 str在start和end之间 在 mystr里面出现的次数 使用方法:str.count("xx",0,len(str)) <4>replace 把 mystr 中的 str1 替换成 str2,如果 count 指定,则替换不超过 count 次. 使用方法:str.replace(str1, str2, str.count(str1)) <5>split 以 str 为分隔符切片 mystr,如果 maxsplit有指定值,则仅分隔 maxsplit 个子字符串 使用方法:str.split(" ", 2) <6>capitalize 把字符串的第一个字符大写 使用方法:str.capitalize() <7>title 把字符串的每个单词首字母大写 使用方法:str.title() <8>startswith 检查字符串是否是以 obj 开头, 是则返回 True,否则返回 False 使用方法:str