博客
关于我
【python】多个list合并
阅读量:160 次
发布时间:2019-02-28

本文共 208 字,大约阅读时间需要 1 分钟。

环境:win7 + python3.5.2

方法一:标准库

from itertools import chaina = [[1,2],[3,4]]a_ = list(chain(*a))print(a_)

运行结果:

[1,2,3,4]

方法二:python风格的写法

a = [[1,2],[3,4]]a_ = [x for j in a for x in j]print(a_)

运行结果:

[1,2,3,4]

转载地址:http://fszc.baihongyu.com/

你可能感兴趣的文章
Mysql之主从复制
查看>>