使用列表推导式实现二维矩阵转置 matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]] print(matrix) matrix_t = [[row[col] for row in matrix] for col in range(len(matrix[0]))] print(matrix_t) #输出结果 #[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]] #[[1, 5, 9], [2, 6, 1