如何在Python中串联两个列表? [英] How do I concatenate two lists in Python?
本文介绍了如何在Python中串联两个列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Python中连接两个列表?
How do I concatenate two lists in Python?
示例:
listone = [1, 2, 3]
listtwo = [4, 5, 6]
预期结果:
>>> joinedlist
[1, 2, 3, 4, 5, 6]
推荐答案
您可以使用+
运算符将它们组合:
You can use the +
operator to combine them:
listone = [1,2,3]
listtwo = [4,5,6]
joinedlist = listone + listtwo
输出:
>>> joinedlist
[1,2,3,4,5,6]
这篇关于如何在Python中串联两个列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文