Python3 字符串
描述
Python strip() 方法用于移除字符串頭尾指定的字符(默認(rèn)為空格)。
語(yǔ)法
strip()方法語(yǔ)法:
str.strip([chars]);
參數(shù)
- chars -- 移除字符串頭尾指定的字符。
返回值
返回移除字符串頭尾指定的字符生成的新字符串。
實(shí)例
以下實(shí)例展示了strip()函數(shù)的使用方法:
#!/usr/bin/python3
str = "*****this is string example....wow!!!*****"
print (str.strip( '*' ))
以上實(shí)例輸出結(jié)果如下:
this is string example....wow!!!
更多建議: