相关疑难解决方法(0)

在Python中删除字符串中的所有空格

我想从字符串,两端和单词之间消除所有空格.

我有这个Python代码:

def my_handle(self):
    sentence = ' hello  apple  '
    sentence.strip()
Run Code Online (Sandbox Code Playgroud)

但这只会消除字符串两边的空白.如何删除所有空格?

python trim removing-whitespace

715
推荐指数
10
解决办法
154万
查看次数

标签 统计

python ×1

removing-whitespace ×1

trim ×1