首页 > 编程语言 > 详细

python中strip()方法学习笔记

时间:2017-09-28 15:29:27      阅读:360      评论:0      收藏:0      [点我收藏+]

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

当使用strip(‘xxx‘),只要字符串头尾有"xxx"中的一个,就会去掉,而不是符合字符串‘‘xxx‘‘才去掉

1 >>> string = aaabbbccc
2 >>> string.strip(abc)
3 ‘‘
4 >>> string2 = aaaffbbcc
5 >>> string2.strip(abc)
6 ff
7 >>> string3 = aaaffbbffcc
8 >>> string3.strip(abc)
9 ffbbff

 

python中strip()方法学习笔记

原文:http://www.cnblogs.com/time-read/p/7606818.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!