这个问题并没有明确你想要达到的目标。
List 有 append 方法,它将其参数附加到列表中:
>>> list_one = [1,2,3]
>>> list_two = [4,5,6]
>>> list_one.append(list_two)
>>> list_one
[1, 2, 3, [4, 5, 6]]
还有extend 方法,它从作为参数传递的列表中附加items:
>>> list_one = [1,2,3]
>>> list_two = [4,5,6]
>>> list_one.extend(list_two)
>>> list_one
[1, 2, 3, 4, 5, 6]
当然,还有insert 方法,其作用类似于append,但允许您指定插入点:
>>> list_one.insert(2, list_two)
>>> list_one
[1, 2, [4, 5, 6], 3, 4, 5, 6]
要在特定插入点扩展列表,您可以使用列表切片(感谢@florisla):
>>> l = [1, 2, 3, 4, 5]
>>> l[2:2] = ['a', 'b', 'c']
>>> l
[1, 2, 'a', 'b', 'c', 3, 4, 5]
列表切片非常灵活,因为它允许将列表中的一系列条目替换为另一个列表中的一系列条目:
>>> l = [1, 2, 3, 4, 5]
>>> l[2:4] = ['a', 'b', 'c'][1:3]
>>> l
[1, 2, 'b', 'c', 5]