0
我想在Python中以列为单位连接两个嵌套列表。这与numpy.hstack()类似,但是在Python列表的基础Python中。我能够以下面的方式做到这一点。有没有更好的,更快的方式来串联嵌套列表?按列连接嵌套的python列表(类似于numpy.hstack())
list_a = [[2, 2], [4, 4], [6, 6]]
list_b = [[1, 1], [3, 3], [5, 5]]
# list_b as array-like
#[2, 2]
#[4, 4]
#[6, 6]
# list_c as array_like
#[1, 1]
#[3, 3]
#[5, 5]
for x,y in zip(list_a,list_b):
x = x + y
# list_a after concatenation
#[2, 2, 1, 1]
#[4, 4, 3, 3]
#[6, 6, 5, 5]