4。python之字符串方法总结

一。私有方法:

1.大小写:upper()和lower()

2.替换:replace()

3.判断是否为数字:isdigit

4.分割字符串:split()

5.消除首尾字符:Strip / rstrip / lstrip

6.字符连接:“_".join(str)

7.字符的格式化:"{0},{1},{2}".format(str,str1,str2)

8.判断是否以“str"开头:startswith / endswith

9.编码:encode,gbk,encode("utf-8“)

猜你喜欢

转载自www.cnblogs.com/jiaodajiage/p/12153846.html
今日推荐