本文共 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/