- 用法:- str.rstrip([chars])
- 返回删除了尾随字符的字符串副本。 - chars参数是一个字符串,指定要删除的字符集。如果省略或- None,则- chars参数默认为删除空格。- chars参数不是后缀;相反,它的值的所有组合都被剥离:- >>> ' spacious '.rstrip() ' spacious' >>> 'mississippi'.rstrip('ipz') 'mississ'- 有关删除单个后缀字符串而不是所有字符集的方法,请参见 - str.removesuffix()。例如:- >>> 'Monty Python'.rstrip(' Python') 'M' >>> 'Monty Python'.removesuffix(' Python') 'Monty'
相关用法
- Python str.removeprefix用法及代码示例
- Python str.removesuffix用法及代码示例
- Python str.isidentifier用法及代码示例
- Python str.expandtabs用法及代码示例
- Python str.isupper用法及代码示例
- Python str.title用法及代码示例
- Python str.splitlines用法及代码示例
- Python str.lstrip用法及代码示例
- Python str.split用法及代码示例
- Python str.zfill用法及代码示例
- Python str.strip用法及代码示例
- Python str.format_map用法及代码示例
- Python str() vs repr()用法及代码示例
- Python string转integer用法及代码示例
- Python string strip()用法及代码示例
- Python string.octdigits用法及代码示例
- Python string.whitespace用法及代码示例
- Python strip()用法及代码示例
- Python str()用法及代码示例
- Python string capitalize()用法及代码示例
注:本文由纯净天空筛选整理自python.org大神的英文原创作品 str.rstrip。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
