[[[1],[2],[3]],
[[4],[5],[6]]]
合并成:
[[1, 2, 3],[4, 5, 6]]
普通版:
l = [[[1],[2],[3]],[[4],[5],[6]]]
def merge_list(list):
dic = {}
for i,j in enumerate(list):
dic[str(i)] = j
for k,v in dic.items():
m = []
for i in v:
m.extend(i)
dic[k] = m
return sorted([x for x in dic.values()],reverse=False)
print merge_list(l)
一行版:
def merge_list(list):
return [[x[0] for x in y] for y in list]