Python 官方文档:入门教程 => 点击学习
python中rstrip是指删除字符串末尾指定字符的方法,rstrip的语法格式“str.rstrip([chars])”,这里chars是指定删除的字符。具体使用步骤:首先打开Python编辑器,新建一个python项目。在python
python中rstrip是指删除字符串末尾指定字符的方法,rstrip的语法格式“str.rstrip([chars])”,这里chars是指定删除的字符。
具体使用步骤:
在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!!!
--结束END--
本文标题: python中rstrip是什么意思
本文链接: https://www.lsjlt.com/news/110009.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0