相关疑难解决方法(0)

加入python中的列表列表

在python中将列表列表加入单个列表(或迭代器)的简短语法是什么?

例如,我有一个如下列表,我想迭代a,b和c.

x = [["a","b"], ["c"]]
Run Code Online (Sandbox Code Playgroud)

我能想到的最好的是如下.

result = []
[ result.extend(el) for el in x] 

for el in result:
  print el
Run Code Online (Sandbox Code Playgroud)

python

284
推荐指数
10
解决办法
31万
查看次数

标签 统计

python ×1