假设你有一个清单:
mylist=[[1,2,3,4],[2,3,4,5],[3,4,5,6]]
任何pythonic(2.x)解压内部列表的方式,以便新列表看起来像?:
mylist_n=[1,2,3,4,2,3,4,5,3,4,5,6]
答案 0 :(得分:3)
import itertools
mylist=[[1,2,3,4],[2,3,4,5],[3,4,5,6]]
print list(itertools.chain(*mylist))
答案 1 :(得分:2)
mylist_n = [j for i in mylist for j in i]