python

python中rstrip是什么意思

摘星
1847
2021-05-31 13:17:54
栏目: 编程语言
Python开发者服务器,限时0元免费领! 查看>>

python中rstrip是指删除字符串末尾指定字符的方法,rstrip的语法格式“str.rstrip([chars])”,这里chars是指定删除的字符。

python中rstrip是什么意思

具体使用步骤:

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

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

相关推荐:python中super是什么意思

0
看了该问题的人还看了