python实现合并两个数组的方法

yipeiwu_com7年前Python基础

本文实例讲述了python实现合并两个数组的方法。分享给大家供大家参考。具体如下:

python合并两个数组,将两个数组连接成一个数组,例如,数组 a=[1,2,3] ,数组 b=[4,5,6],连接后:[1,2,3,4,5,6]

方法1

a=[1,2,3]
b=[4,5,6]
a=a+b

方法2

a=[1,2,3]
b=[4,5,6]
a.extend(b)

希望本文所述对大家的Python程序设计有所帮助。

相关文章

详解python 字符串和日期之间转换 StringAndDate

python 字符串和日期之间转换 StringAndDate           这里给出实现...

python使用tomorrow实现多线程的例子

python使用tomorrow实现多线程的例子

如下所示: import time,requestes from tomorrow import threads @threads(10)#使用装饰器,这个函数异步执行 def d...

PyQt5图形界面播放音乐的实例

安装Pygame pip install pygame import time import pygame pygame.init() print("播放音乐1") track =...

Python实现批量将word转html并将html内容发布至网站的方法

本文实例讲述了Python实现批量将word转html并将html内容发布至网站的方法。分享给大家供大家参考。具体实现方法如下: #coding=utf-8 __author__ =...

使用Python实现分别输出每个数组

我就废话不多说了,直接上代码吧! a=[[1,2,3],[4,5][6,7]["a","b"",c"]] # i=0 # while i<len(a): # print(a...