我正在尝试弄清楚如何从列表中取消合并一堆列表。例如,来自
parent_list = [ [a, b, c], [d, e, f], [g, h, i] ]
到
child_list1 = [a, b, c]
child_list2 = [d, e, f]
child_list3 = [g, h, i]
最佳答案
使用unpacking :
>>> parent_list = [['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i']]
>>> child_list1, child_list2, child_list3 = parent_list
>>> child_list1
['a', 'b', 'c']
>>> child_list2
['d', 'e', 'f']
>>> child_list3
['g', 'h', 'i']
>>>
关于python - 如何取消合并 python 列表中的列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22412839/