python将两个数组合并成一个数组的两种方法的代码
Posted 菜鸟院长
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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"]
以上是关于python将两个数组合并成一个数组的两种方法的代码的主要内容,如果未能解决你的问题,请参考以下文章