更新:抱歉,伙计们,我想说的是一个列表,在一个列表中。你知道吗
如何使用分隔符将列表中的项目拆分为另一个列表中的项目。例如:
x = [['temp1_a','temp2_b', None, 'temp3_c'],['list1_a','list2_b','list3_c']]
理想情况下,我想把它们分成一本字典,所以:
y = ['temp1','temp2', None, 'temp3','list1','list2','list3']
z = ['a','b', None, 'c','a','b','c']
我确信它使用了split,但是当我尝试使用它时,我得到的“list”对象没有属性“split”。你知道吗
使用列表理解。你知道吗
更新:
有很多方法可以做到这一点。。。你知道吗
下面是如何使用^{} :
第二行右侧的表达方式只是一种优雅的书写方式:
相关问题 更多 >
编程相关推荐