一尘不染

如何在 Python 中连接两个列表?

python

如何在 Python 中连接两个列表?

例子:

listone = [1, 2, 3]
listtwo = [4, 5, 6]

预期结果:

>>> joinedlist
[1, 2, 3, 4, 5, 6]

阅读 251

收藏
2022-01-19

共1个答案

一尘不染

您可以使用+运算符来组合它们:

listone = [1, 2, 3]
listtwo = [4, 5, 6]

joinedlist = listone + listtwo

输出:

>>> joinedlist
[1, 2, 3, 4, 5, 6]
2022-01-19