Python--strip()学习记录
2018-03-30 12:32
204 查看
用法一:strip()方法返回除去两侧(不包框内部)空格的字符串
用法二:除去指定的字符串
示例1:s = "******* this ******* in!! !!!*****"
print(s)
s = s.strip('*!')
print(s)输出:******* this ******* in!! !!!*****
this ******* in!! 示例2:s = "***@**** this ******* in!! !!!*****#"
print(s)
s = s.strip('*@#!')
print(s)输出:***@**** this ******* in!! !!!*****#
this ******* in!!
欢迎留言交流!
用法二:除去指定的字符串
示例1:s = "******* this ******* in!! !!!*****"
print(s)
s = s.strip('*!')
print(s)输出:******* this ******* in!! !!!*****
this ******* in!! 示例2:s = "***@**** this ******* in!! !!!*****#"
print(s)
s = s.strip('*@#!')
print(s)输出:***@**** this ******* in!! !!!*****#
this ******* in!!
欢迎留言交流!
相关文章推荐
- Python3.5入门学习记录-File
- Python学习记录
- 流畅的python第三章字典和集合学习记录
- python 第二天学习记录
- Python学习记录
- python协程学习记录(1)
- Python学习记录----数据定义
- python学习记录之_1025
- python 学习记录(7)-循环/结构化程序(冒泡排序)
- Python学习记录_Day009
- Python学习记录03
- python学习记录
- python第27天学习记录
- python基础学习笔记(个人学习时记录的笔记,不全的地方请大家指正)
- python学习笔记,以此开始记录自己的python学习过程
- python爬虫学习记录之报错及解决方案
- python学习-知识点记录(Temp)
- Python模块学习 ---- logging 日志记录(一)
- python学习记录