python: strip()函数
来源:互联网 发布:js获取css样式表 编辑:程序博客网 时间:2024/06/01 22:26
函数原型
声明:s为字符串,rm为要删除的字符序列
s.strip(rm) 删除s字符串中开头、结尾处,位于 rm删除序列的字符
s.lstrip(rm) 删除s字符串中开头处,位于 rm删除序列的字符
s.rstrip(rm) 删除s字符串中结尾处,位于 rm删除序列的字符
举例说明
rm为空时,默认删除空白符(包括'\n', '\r', '\t', ' ')
>>> b = '\rabc\t\n'>>> b.strip()'abc'>>> b = '\ra\r\t\nbc\t\n' #只会删除开头或结尾处>>> b.strip()'a\r\t\nbc'rm不为空,会删除 开头或结尾 含有rm中的字符
>>> b.strip('12')'3abc'>>> b.strip('21') # 没有顺序'3abc'>>> b.strip('31') # 只要开头和结尾中含有 rm 字符 就删除'23abc'>>> b.strip('bc')'123a'
本文主要参考:http://www.jb51.net/article/37287.htm?_t=1490083426226&_t=1490083426288
0 0
- python strip()函数 介绍
- python strip()函数 介绍
- python strip()函数
- python中的strip函数
- python strip()函数 介绍
- python strip()函数
- Python的strip函数
- python strip()函数
- python strip() split()函数
- python strip()函数
- python strip()函数
- python strip()函数
- python strip()函数
- python strip()函数
- python strip()函数
- Python strip() 函数
- 【Python】strip函数
- Python strip函数
- 存储过程调用存储过程数据集的方法
- Word测试发博客
- java接口 (springmvc)
- 第二个ffmpeg程序,视频播放
- 算法导论 练习题 4.1-5
- python: strip()函数
- cuda8.0配置opencv2.4.9可能遇到的两个问题
- AAC格式文件解析
- CSDN学霸课表——iOS人机交互设计规范精讲
- eclipse提示Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-com
- hive行转列lateral view explode用法
- RxJava-操作符
- MySQL必知必会-18MySQL更新数据
- FineReport中如何自定义登录界面