删除字符串中的空格

strx = "hello world ! this is Python"
x=strx.replace(" ", "")
print(x)
print(strx)
strx = strx.split(' ')
strx = ''.join(strx)

print(strx)

输出

helloworld!thisisPython
hello world ! this is Python                                helloworld!thisisPython                                     [Program finished]
原文地址:https://www.cnblogs.com/sea-stream/p/11190510.html