python 列表推导式,双重for循环
作者:互联网
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]
标签:flat,sub2,推导,sub1,python,list,列表,print,my 来源: https://www.cnblogs.com/wlike/p/16697458.html