您的位置:首页 > 编程语言 > Python开发

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!!!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: