难度:
点击显示代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
jz1 = [ [1, 2, 3], [4, 5, 6], ] jz1_row_len = len(jz1) jz1_col_len = len(jz1[0]) jz2 = [] jz2_row_len = jz1_col_len jz2_col_len = jz1_row_len for i in range(jz2_row_len): row = [] for j in range(jz1_row_len): row.append(jz1[j][i]) jz2.append(row) print(f'源矩阵为:{jz1}') print(f'转置矩阵为:{jz2}')
1 2
源矩阵为:[[1, 2, 3], [4, 5, 6]] 转置矩阵为:[[1, 4], [2, 5], [3, 6]]
=== 全文完 ===