Python rStrip()返回字符串的副本,其中所有字符都已从字符串的末尾剥离(默认空格字符)。
rstrip() - 语法
str.rstrip([chars])
chars - 您可以提供必须修剪的字符。
rstrip() - 返回值
此方法返回字符串的副本,其中所有字符都已从字符串的末尾剥离(默认空格字符)。
rstrip() - 示例
以下示例显示了rStrip()方法的用法。
#!/usr/bin/pythonstr=" 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!!!