Python 将一个列表的数组追加到另一个列表的数组中
我有两个列表,每个列表都包含数组。我想将一个列表的数组附加到另一个列表的数组的末尾。我的意思是:Python 将一个列表的数组追加到另一个列表的数组中,python,arrays,list,Python,Arrays,List,我有两个列表,每个列表都包含数组。我想将一个列表的数组附加到另一个列表的数组的末尾。我的意思是: inp1 = [np.array([[2.5, 1.5, 0.]]), np.array([[3., 2., 0.], [2.1, 2., -1.]])] inp2 = [np.array([[10., 20., 30.]]), np.array([[100., 100., 100.], [200., 200., 400.]])] 然后,我想在inp1的第一个数组
inp1 = [np.array([[2.5, 1.5, 0.]]),
np.array([[3., 2., 0.], [2.1, 2., -1.]])]
inp2 = [np.array([[10., 20., 30.]]),
np.array([[100., 100., 100.], [200., 200., 400.]])]
然后,我想在inp1
的第一个数组末尾追加inp2
的第一个数组。然后,在inp1
的第二个ned处插入第二个inp2
,依此类推。我希望得到如下结果:
outp= [np.array([[2.5, 1.5, 0.],
[10., 20., 30.]]),
np.array([[3., 2., 0.],
[2.1, 2., -1.],
[100., 100., 100.],
[200., 200., 400.]])]
我尝试了以下方法,但得到了另一个结果:
outp1=zip(inp1, inp2)
outp1=list(outp1)
实际上,我在inp1
和inp2
中存储了数百个数组,这是怎么回事
l = [np.append(array, to_append, axis=0) for (array, to_append) in zip(inp1, inp2)]
print(l)
亲爱的@tgrandje,非常感谢。这正是我需要的。