python strip()

Grammar:

str.strip([chars]);

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

参数

chars -- 移除字符串头尾指定的字符。

返回值

返回移除字符串头尾指定的字符生成的新字符串。

Case:

1 #coding:utf-8
2 str='aaabba888aaahttp://www.cnblogs.com/sub2020/aaabbaa88877777888aaa'
3 print str.strip('ab78')
4 #Output
5 http://www.cnblogs.com/sub2020/

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

原文地址:https://www.cnblogs.com/sub2020/p/7977978.html