split(), shlex.split(), strip(), lstrip(), rstrip()

http://www.runoob.com/python/att-string-split.html
http://www.runoob.com/python/att-string-strip.html
str.split(str="", num=string.count(str)).
  • str -- 分隔符,默认为所有的空字符,包括空格、换行(\n)、制表符(\t)等。
  • num -- 分割次数。默认为 -1, 即分隔所有。

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

注意:该方法只能删除开头或是结尾的字符,不能删除中间部分的字符。

 lstrip() 方法用于截掉字符串左边的空格或指定字符。

str.lstrip([chars]) : chars --指定截取的字符。

rstrip() 删除 string 字符串末尾的指定字符(默认为空格)

猜你喜欢

转载自blog.csdn.net/weixin_42205776/article/details/88956543