我需要删除字符串中单词后的空格。这可以在一行代码中完成吗?
例子:
string = " xyz "
desired result : " xyz"
最佳答案
>>> " xyz ".rstrip()
' xyz'
the documentation 中有更多关于 rstrip
的内容.
关于python - 如何从 Python 中的字符串末尾删除空格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2372573/