我的函数输出都是在不同行上断开的所有值,我想把它变成一个列表。
The Score
Leon the Professional
Iron Man
我想把它变成这样的列表:
movies= ['The Score', 'Leon the Professional', 'Iron Man']
我该怎么做呢?
请您参考如下方法:
假设您的输入是一个字符串。
>>> text = '''The Score
Leon the Professional
Iron Man'''
>>> text.splitlines()
['The Score', 'Leon the Professional', 'Iron Man']
有关 splitlines() 的更多信息功能。
