bbb 方法学 python pytho ring strip strip() clas ng2
Python strip() 方法用于移除字符串头尾指定的字符(默认为空格)。
当使用strip(‘xxx‘),只要字符串头尾有"xxx"中的一个,就会去掉,而不是符合字符串‘‘xxx‘‘才去掉
- >>> string = ‘aaabbbccc‘
- >>> string.strip(‘abc‘)
- ‘‘
- >>> string2 = ‘aaaffbbcc‘
- >>> string2.strip(‘abc‘)
- ‘ff‘
- >>> string3 = ‘aaaffbbffcc‘
- >>> string3.strip(‘abc‘)
- ‘ffbbff‘
python中strip()方法学习笔记
来源: http://www.bubuko.com/infodetail-2329252.html