2015-10-11 112 views
-7

有行和行有空格,所以我想摆脱空格只留下字符串。如何摆脱行中的空格,python

空间,如“”,“”,“” 所以我应该使用的代码删除空间?

Thnks

+5

也许你可以包括一些例如线,预计输出配对?目前还不清楚你在这里要求什么。 –

回答

2
st = " with, or, without , spaces   "; 
st = st.replace(" ","") 
print(st) 
with,or,without,spaces 
0

你可以使用的

sys.stdout.write("something") 
sys.stdout.write("without") 
sys.stdout.write("spaces") 

代替

print "something", "without", "spaces"