问题:
I want to eliminate all the whitespace from a string, on both ends, and in between words. 我想消除字符串两端和单词之间的所有空白。
I have this Python code: 我有这个Python代码:
def my_handle(self):
sentence = ' hello apple '
sentence.strip()
But that only eliminates the whitespace on both sides of the string. 但这仅消除了字符串两侧的空白。 How do I remove all whitespace? 如何删除所有空格?
解决方案:
参考一: https://stackoom.com/question/YhQa/在Python中删除字符串中的所有空格参考二: https://oldbug.net/q/YhQa/Remove-all-whitespace-in-a-string-in-Python
来源:oschina
链接:https://my.oschina.net/u/3797416/blog/4335862