嵌套列表拆解

import itertools       # 列表嵌套的拆解

a = [ [(1,2),(2,3),(5,6)], [(22,33),(12,78)] ]
new_a = list( itertools.chain.from_iterable(a) )

## 结果:
[(1, 2), (2, 3), (5, 6), (22, 33), (12, 78)]
posted @ 2023-03-23 14:34  云飞01  阅读(20)  评论(0编辑  收藏  举报