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