您好,我有一个字符串列表,如下所示
x = [["and bee cos dup ete", "ans bew coa duo etr"], ["snd nee vos fup rte", "sns new voa fuo rtr"]]
我希望从列表列表中用空格分隔的字符串中创建另一个列表,即:
x = [[[and,bee,cos,dup,ete], [ans,bew,coa,duo,etr]], [[snd,nee,vos,fup,rte], [sns,new,voa,fuo,rtr]]]
我试过了
for i in x:
for y in i:
y.split()
但这是行不通的
你可以做:
一般解决方案:
对于上述特殊情况
输出:
给你
输出:
编辑 您也可以这样做,只需一个
for loop
:同样的结果
相关问题 更多 >
编程相关推荐