说我有
x = "this string"
我试图在不同的行上打印这两个词。我在想我需要以某种方式使用 string.split()
但我不确定如何使用。
最佳答案
你可以使用这个:
print '\n'.join(x.split())
在哪里
x = 'this string'
x.split() # ['this', 'string']
关于Python:如何打印在不同行上包含多个单词的字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15785215/