Python的内置函数(三十七)、 rstrip()

Python的内置函数(三十七)、 rstrip()参考 Python 的内置函数 三十八 rstrip 云 社区 腾讯云 描述 Python rstrip 删除 string 字符串末尾的指定字符 默认为空格 语法 rstrip 方法语法 str rstrip chars 参数 chars

大家好,我是讯享网,很高兴认识大家。

参考   Python的内置函数(三十八)、 rstrip() - 云+社区 - 腾讯云

描述

Python rstrip() 删除 string 字符串末尾的指定字符(默认为空格).

语法

rstrip()方法语法:


讯享网

str.rstrip([chars])

讯享网

参数

  • chars -- 指定删除的字符(默认为空格)

返回值

  • 返回删除 string 字符串末尾的指定字符后生成的新字符串。

实例

以下实例展示了rstrip()函数的使用方法:

讯享网#!/usr/bin/python str = " this is string example....wow!!! " print(str.rstrip()) str = "this is string example....wow!!!" print(str.rstrip('8')) Output: ------------------------------------------ this is string example....wow!!! this is string example....wow!!! ------------------------------------------

小讯
上一篇 2025-01-18 23:58
下一篇 2025-01-19 08:21

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/15634.html