my_list = [
[[1, 2, 3], [4, 5, 6]]
]
flat = [x for sub1 in my_list for sub2 in sub1 for x in sub2]
print(flat)
# [1, 2, 3, 4, 5, 6]
flat2 = [((x for x in sub2) for sub2 in sub1) for sub1 in my_list]
print(list(flat))
# [1, 2, 3, 4, 5, 6]
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/289639.html