strip是什么意思(python中strip指的是什么意思)

发布时间:2025-12-10 23:04:33 浏览次数:2

python中strip是字符串中的方法。

Python strip() 方法用于移除字符串头尾指定的字符(默认为空格)或字符序列。

注意:该方法只能删除开头或是结尾的字符,不能删除中间部分的字符。

strip()方法语法:

str.strip([chars]);

参数

chars -- 移除字符串头尾指定的字符序列。

返回值

返回移除字符串头尾指定的字符序列生成的新字符串。

实例

以下实例展示了 strip() 函数的使用方法:

#!/usr/bin/python3str = "*****this is **string** example....wow!!!*****"print (str.strip( '*' ))  # 指定字符串 *
this is **string** example....wow!!!

从结果上看,可以注意到中间部分的字符并未删除。

strip是什么意思
需要做网站?需要网络推广?欢迎咨询客户经理 13272073477