#It will take space as a {character} and 'space' it.
x = input("Enter:") # hello world
print(" ".join(x)) # h e l l o _ w o r l d {*_ as a space character}
#If you not wanted space as a {character}
y=input("Enter: ") # hello world
y=y.replace(" ","") #Removed spaces
print(" ".join(y)) # h e l l o w o r l d
3条答案
按热度按时间j5fpnvbx1#
正如John在评论中所说,您可以使用
str.join
来实现这一点:ujv3wf0j2#
如果要像这样拆分文本:
'lorem ipsum'
到['lorem','ipsum']
,您可以使用x = string.split()
。f1tvaqid3#