python strip()函数
来源:互联网 发布:c语言do-while的用法 编辑:程序博客网 时间:2024/06/11 07:14
声明:s为字符串,rm为要删除的字符序列
s.strip(rm) 删除s字符串中开头、结尾处,位于 rm删除序列的字符
s.lstrip(rm) 删除s字符串中开头处,位于 rm删除序列的字符
s.rstrip(rm) 删除s字符串中结尾处,位于 rm删除序列的字符
注意:
1. 当rm为空时,默认删除空白符(包括'\n', '\r', '\t', ' ')
例如:
代码如下:
>>> a = ' 123'
>>> a.strip()
'123'
>>> a='\t\tabc'
'abc'
>>> a = 'sdff\r\n'
>>> a.strip()
'sdff'
2.这里的rm删除序列是只要边(开头或结尾)上的字符在删除序列内,就删除掉。
例如 :
代码如下:
>>> a = '123abc'
>>> a.strip('21')
'3abc' 结果是一样的
>>> a.strip('12')
'3abc'
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函数
- 数据挖掘知识梳理脑图
- python的numpy和matplotlib包的安装
- SprignMVC+myBatis整合(一)—— 基于MapperFactoryBean
- 学生成绩管理代码(c代码)
- [poj 2948] Martian Mining 棋盘型DP
- python strip()函数
- hdu 4717 The Moving Points
- nosql数据库不提供事务
- 14、迭代器模式(Iterator)
- MyBatis
- 字节、字、bit、byte的关系
- Nginx Location处理逻辑(优先级)权威解读
- 排序(五)---基数排序
- 香港坐标系