Python 字符串
描述
Python rstrip() 刪除 string 字符串末尾的指定字符(默認(rèn)為空格).
語(yǔ)法
rstrip()方法語(yǔ)法:
str.rstrip([chars])
參數(shù)
chars – 指定刪除的字符(默認(rèn)為空格)
返回值
返回刪除 string 字符串末尾的指定字符后生成的新字符串。
實(shí)例
以下實(shí)例展示了rstrip()函數(shù)的使用方法:
#!/usr/bin/pythonstr = " this is string example…wow!!! ";print str.rstrip();str = “88888888this is string example…wow!!!8888888”;print str.rstrip(‘8');
以上實(shí)例輸出結(jié)果如下:
this is string example....wow!!!
88888888this is string example…wow!!!
總結(jié)
以上所述是小編給大家介紹的Python rstrip()方法實(shí)例詳解,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)歡迎給我留言,小編會(huì)及時(shí)回復(fù)大家的!
新聞熱點(diǎn)
疑難解答
圖片精選