<分区>
让我们举个例子:
nodes = [[1, 2],[3, 4]]
thelist = [[5, 6], [7, 8]]
如何编写代码以便列表为:
[[1, 2],[3, 4],[5, 6],[7, 8]]
我知道怎么做,但我想要一种优雅的 python 方式。
我的尝试:
for node in nodes:
thelist.insert(0, node)
我想应该有一个更 pythonic 的方式来做到这一点。
编辑:顺序在某种程度上很重要(这就是我尝试在索引 0 处插入的原因)。