是否有一个Python函数可以从字符串中修剪空格(空格和制表符)?
示例:\t example string\t→example string
我想从字符串,两端和单词之间消除所有空格.
我有这个Python代码:
def my_handle(self):
sentence = ' hello apple '
sentence.strip()
Run Code Online (Sandbox Code Playgroud)
但这只会消除字符串两边的空白.如何删除所有空格?