Python rstrip()方法实例详解
作者:阿特密斯X 时间:2021-05-16 10:05:40
Python 字符串
描述
Python rstrip() 删除 string 字符串末尾的指定字符(默认为空格).
语法
rstrip()方法语法:
str.rstrip([chars])
参数
chars – 指定删除的字符(默认为空格)
返回值
返回删除 string 字符串末尾的指定字符后生成的新字符串。
实例
以下实例展示了rstrip()函数的使用方法:
#!/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()方法实例详解,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!
来源:https://blog.csdn.net/qq_42194192/article/details/83957835
标签:Python,rstrip()
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python实现大文本文件分割
2023-09-03 10:00:53
int在python中的含义以及用法
2023-07-28 08:48:21
CentOS 6.6服务器编译安装lnmp(Nginx1.6.2+MySQL5.6.21+PHP5.6.3)
2023-11-15 06:40:50
![](https://img.aspxhome.com/file/2023/6/64186_0s.jpg)
网页iframe元素应用浅析
2009-04-11 18:11:00
Python中pip工具的安装以及使用
2023-12-12 18:42:37
![](https://img.aspxhome.com/file/2023/1/79601_0s.png)
在Python开发环境中调用ChatGPT模型详细过程
2022-03-25 21:59:29
![](https://img.aspxhome.com/file/2023/3/97603_0s.jpg)
浅析python打包工具distutils、setuptools
2021-03-30 14:45:14
![](https://img.aspxhome.com/file/2023/2/65132_0s.png)
Python基于动态规划算法计算单词距离
2021-09-18 11:18:16
python调用虹软2.0第三版的具体使用
2022-03-23 06:32:19
pandas带有重复索引操作方法
2023-04-19 20:22:12
Python判断变量是否已经定义的方法
2023-08-01 07:14:01
详解如何利用Python制作24点小游戏
2022-02-04 17:22:42
![](https://img.aspxhome.com/file/2023/2/66882_0s.jpg)
Python中pip安装非PyPI官网第三方库的方法
2021-01-20 15:51:18
python生成n个元素的全组合方法
2023-11-10 20:35:08
python查询MySQL将数据写入Excel
2023-12-15 13:48:11
![](https://img.aspxhome.com/file/2023/8/70868_0s.png)
SQL对时间处理的语句小结
2011-12-01 07:53:04
IE9硬件加速性能远超Chrome5.0和Firefox4.0
2010-06-09 11:12:00
![](https://img.aspxhome.com/file/UploadPic/20106/9/img20100612757087130-68s.jpg)
python fabric实现远程操作和部署示例
2021-07-18 14:22:14
pytorch Dropout过拟合的操作
2023-11-26 16:12:18
![](https://img.aspxhome.com/file/2023/7/80607_0s.jpg)
Python实现提取给定网页内的所有链接
2022-03-29 19:01:11
![](https://img.aspxhome.com/file/2023/4/80814_0s.webp)