欢迎光临
我们一直在努力

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!!!

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。