第一个理解相当于:flat = []for row in matrix: for x in row: flat.append(x)第二种理解等价于:squared = []for row in matrix: tmp = [] for x in row: tmp.append(x**2) squared.append(tmp)(除了在封闭范围内创建其他变量,如x, row, tmp。)