2022
我们一起努力

python中rstrip是什么意思

pythonrstrip是指删除字符串末尾指定字符的方法,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!!!

赞(0)
文章名称:《python中rstrip是什么意思》
文章链接:https://www.fzvps.com/91269.html
本站文章来源于互联网,如有侵权,请联系管理删除,本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。
图片版权归属各自创作者所有,图片水印出于防止被无耻之徒盗取劳动成果的目的。

评论 抢沙发

评论前必须登录!