python将两个数组合并成一个数组的两种方法的代码

内容过程中,把写内容过程中常用的内容收藏起来,下面的资料是关于python将两个数组合并成一个数组的两种方法的内容,希望能对小伙伴们有帮助。
c1 = ["Red","Green","Blue"]
c2 = ["Orange","Yellow","Indigo"]
c1.extend(c2)

assert c1 == ["Red","Green","Blue","Orange","Yellow","Indigo"]





下面使用+号操作符



c1 = ["Red","Green","Blue"]
c2 = ["Orange","Yellow","Indigo"]
c3 = c1 + c2

assert c3 == ["Red","Green","Blue","Orange","Yellow","Indigo"]




 

posted @ 2019-02-07 14:52  菜鸟院长  阅读(22478)  评论(0编辑  收藏  举报