Python将两个列表/数组合并成一个列表/数组
- extend方法
>>>c1 = ["Red","Green","Blue"] >>>c2 = ["Orange","Yellow","Indigo"] >>>c1.extend(c2) >>>c1 #["Red","Green","Blue","Orange","Yellow","Indigo"]
- 直接相加
>>>c1 = ["Red","Green","Blue"] >>>c2 = ["Orange","Yellow","Indigo"] >>>c3 = c1 + c2 >>>c3 # ["Red","Green","Blue","Orange","Yellow","Indigo"]