Python strip()方法
2016-06-19 17:51
281 查看
Python strip()方法
描述
Python strip() 方法用于移除字符串头尾指定的字符(默认为空格)。语法
strip()方法语法:str.strip([chars]);
参数
chars -- 移除字符串头尾指定的字符。返回值
返回移除字符串头尾指定的字符生成的新字符串。实例
以下实例展示了strip()函数的使用方法:#!/usr/bin/python str = "0000000this is string example....wow!!!0000000"; print str.strip( '0' );
以上实例输出结果如下:
this is string example....wow!!!
相关文章推荐
- 使用 twisted 的 txrestapi 模块提供基本的异步 API 服务。
- Python 自带小工具
- Python中处理DataFrame,R绘图
- 关于Python的配置文件
- Python-format函数
- List列表的用法以及使用
- 运行python程序
- Ubuntu 16.04下指定Sublime Text 3 默认python编译版本
- Python字典的内置方法
- python开发环境搭建 (eclipse)
- python3实现读取chrome浏览器cookie
- python中splite()返回值
- Python-zip函数
- python3 实现的人人影视网站自动签到
- Python的字节编译
- __setattr__,setattr(),getattr__,getattr()及__getattribute__的区别
- Python-第三方库requests详解
- Python列表的内置方法
- python3 sorted的用法
- Python 字符串