python如何合并两个列表的内容

2025-04-08 14:51:51
推荐回答(2个)
回答1:

>>> list1 = [1,2,3,4]
>>> list2 = [5,6,7,8]
>>> list1+list2
[1, 2, 3, 4, 5, 6, 7, 8]

回答2:

~$ python
Python 2.7.3 (default, Mar 14 2014, 11:57:14) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> a = [1, 2, 5, 8 ,12]
>>> b = [25, 13, 6, 9]
>>> a + b
[1, 2, 5, 8, 12, 25, 13, 6, 9]
>>>