所以说我有
x = "this string"
Run Code Online (Sandbox Code Playgroud)
我试图在不同的行上打印这两个单词.我想我需要以string.split()某种方式使用,但我不确定如何使用.
你可以用这个:
print '\n'.join(x.split())
Run Code Online (Sandbox Code Playgroud)
哪里
x = 'this string'
x.split() # ['this', 'string']
Run Code Online (Sandbox Code Playgroud)