温馨提示×

python中怎么用concat函数连接两个列表

小亿
109
2023-11-30 19:06:16
栏目: 编程语言

在Python中,可以使用"+"运算符将两个列表连接起来。这相当于使用concat函数连接两个列表。下面是一个示例:

list1 = [1, 2, 3]
list2 = [4, 5, 6]

result = list1 + list2
print(result)

输出结果为:

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

通过使用"+"运算符,可以将list1和list2连接成一个新的列表result。

0