定义:
Python strip() 方法用于移除字符串头尾指定的字符(默认为空格)。
语法:
str.strip([chars]);
返回值:
返回移除字符串头尾指定的字符生成的新字符串。
例子:
>>> str = "0000000this is string example....wow!!!0000000" >>> str.strip('0') 'this is string example....wow!!!'
博客园 © 2004-2026 浙公网安备 33010602011771号 浙ICP备2021040463号-3