一、find 查找字符串是否在 如果有反回索引值 如果没有返回-1

二、index 用法同 find 若查找的字符串不在回报错

三、count 计算字符串出现的次数

四、replace 替换 如果有count指定 则不会超过count指定数字

五、split 分隔字符串 如果后边有指定数字 则分隔为几个

六、capitalize 大写字符串第一个字母

七、title 字符串里每个单词首字母大写

八、startswith 检测字符串是否以(xx)开头

九、endswith 检测字符串是否以()结尾

十、lower 将字符串里所有大写转换为小写

十一、upper 将字符串所有小写转换为大写

十二、ljust 左对齐

十三、rjust 右对齐

十四、center 居中

十五、lstrip 删除左边字符串

十六、 rstrip 删除右边字符串

十七、strip 删除两边字符串
十八、partition 分割成三部分,str前,str和str后

十九、rpartition 类似partition 不过是从右边开始
二十、splitlines 按照行分隔,返回一个包含各行作为元素的列表

二十一、isalpha 如果字符串所有字符都是字母 则返回 True,否则返回 False

二十二、isdigit 如果字符串只包含数字则返回 True 否则返回 False.

二十三、isalnum 所有字符都是字母或数字则返回 True,否则返回 False

二十四、isspace 只包含空格,则返回 True,否则返回 False.

二十五、join 每个字符后面插入str,构造出一个新的字符串

网友评论