
python中可以使用rstrip()方法删除 string 字符串末尾的指定字符(默认为空格)。
rstrip()方法语法:str.rstrip([chars])
chars -- 指定删除的字符(默认为空格)
返回值:返回删除 string 字符串末尾的指定字符后生成的新字符串。
示例:
1 2 3 4 5 6 |
|
输出结果如下:
this is string example....wow!!!
*****this is string example....wow!!!
更多Python知识请关注Python视频教程栏目。