[(x, y) for x in [1,2,3] for y in [3,1,4] if x != y]:
[str(round(pi, i)) for i in range(1, 6)]
表达式嵌套
[[row[i] for row in matrix] for i in range(2)]
字典生成式
{x: x**2 for x in (2, 4, 6)}
集合生成式,set会去重,并顺序排列
小括号的,生成器
[(x, y) for x in [1,2,3] for y in [3,1,4] if x != y]:
[str(round(pi, i)) for i in range(1, 6)]
表达式嵌套
[[row[i] for row in matrix] for i in range(2)]
字典生成式
{x: x**2 for x in (2, 4, 6)}
集合生成式,set会去重,并顺序排列
小括号的,生成器