python中字符串相关

str.split(s="", num=string.count(s))

s -- 分隔符,默认为所有的空字符,包括空格、换行( )、制表符( )等。

num -- 分割次数。

输出的是一个list。

str.strip([chars])

Python strip() 方法用于移除字符串头尾指定的字符(默认为空格或换行符)或字符序列

str.count(sub, start= 0,end=len(string))

统计字符串中的某个字符/某个子字符串出现次数

 

参考:

http://www.runoob.com/python3/python3-string-split.html

http://www.runoob.com/python/att-string-strip.html

原文地址:https://www.cnblogs.com/sbj123456789/p/9464447.html