删除字符串中的空格

 

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]

 

posted @ 2019-07-15 18:09  anobscureretreat  阅读(504)  评论(0)    收藏  举报