a=[[1,2],[3,4],[5,6]] x=[j for i in a for j in i ] print(x) import numpy as np b=np.array(a).flatten().tolist() print(b)
结果:
[1, 2, 3, 4, 5, 6] [1, 2, 3, 4, 5, 6]
a=[[1,2],[3,4],[5,6]] x=[j for i in a for j in i ] print(x) import numpy as np b=np.array(a).flatten().tolist() print(b)
结果:
[1, 2, 3, 4, 5, 6] [1, 2, 3, 4, 5, 6]