python中rstrip是什么意思
生活随笔
收集整理的這篇文章主要介紹了
python中rstrip是什么意思
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
python中rstrip是指刪除字符串末尾指定字符的方法,rstrip的語法格式“str.rstrip([chars])”,這里chars是指定刪除的字符。
具體使用步驟:
1、首先打開python編輯器,新建一個python項目。
2、在python項目中使用rstrip方法來刪除刪除字符串末尾指定字符。
print str.rstrip('8'); #刪除字符串末尾為“8”的字符
示例代碼:
#!/usr/bin/python
str = " this is string example....wow!!! ";
print str.rstrip();
str = "88888888this is string example....wow!!!8888888";
print str.rstrip('8');
輸出結果:
this is string example....wow!!!
88888888this is string example....wow!!!
總結
以上是生活随笔為你收集整理的python中rstrip是什么意思的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java的简单工厂模式_java设计模式
- 下一篇: 拼多多怎么查看评价记录 拼多多查看评价记