Python Strip()函数
来源:互联网 发布:淘宝卖虚拟商品 编辑:程序博客网 时间:2024/05/20 23:29
基础知识补一下。
函数原型
声明: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函数
- 实现复数类中的运算符重载 完整类
- 形状类族的中的纯虚函数
- EXC_BAD_ACCESS异常 _block_invoke 问题
- 设计模式----开篇
- hostapd wpa_supplicant madwifi详细分析(十)——wps原理及实现 二
- Python Strip()函数
- iOS 将Log日志重定向输出到文件中保存
- 关于C的复习
- Mac OS X用当前选中的文字生成便签的快捷键是什么
- java字符串
- leetcode #97 in cpp
- SharePoint Document Library中的"Versioning Settings"功能与CSOM的对应
- JSF基本搭建流程
- Time类中的运算符重载