我在用Python 我的名单是
str = ["Hello dude", "What is your name", "My name is Chetan"]
我想将字符串中每个句子中的每个单词分开,并将其存储在新的\u列表中。新列表如下
new_list = ["Hello", "dude", "What", "is", "your", "name", "My", "name",
"is", "Chetan"]
我试过密码
for row in str:
new_list.append(row.split(" "))
输出:
[['Hello', 'dude'], ['What', 'is', 'your', 'name'], ['My', 'name', 'is',
'Chetan']]
哪一个是列表的列表
你可以用^{}
演示
这应该会有帮助。使用
extend
或+=
代替append输出:
相关问题 更多 >
编程相关推荐