1 #嵌套列表解析,讲3*4的矩阵转换成4*3的矩阵 2 3 matrix = [[1, 2, 3, 4], 4 [5, 6, 7, 8], 5 [9, 10, 11, 12]] 6 7 8 for row in matrix: 9 print("遍历每一行:",row) 10 11 12 print(" \n ") 13 14 s = [[row[i] for row in matrix] for i in range(4)] 15 print(s)
标签:转换成,matrix,Python,矩阵,嵌套,print,row From: https://www.cnblogs.com/bravesunforever/p/17674588.html