在python中,[variable2 for variable1 in variable2]的意思是什么

时间:2016-05-24 16:13:44

标签: python

我对这种语法感到困惑。它还是一个清单吗?为什么要在列表中添加for语句? The code comes from here

1 个答案:

答案 0 :(得分:0)

这是一种动态生成列表的方法,称为列表理解。

https://docs.python.org/2/tutorial/datastructures.html#list-comprehensions