二维数组顺时针旋转90°

  老师布置的任务

  python实现

import numpy as np
matrix = [[1, 2, 3],
          [4, 5, 6],
          [7, 8, 9]]
matrix = [[1, 2, 3, 4, 5],
          [6, 7, 8, 9, 10],
          [11, 12, 13, 14, 15],
          [16, 17, 18, 19, 20],
          [21, 22, 23, 24, 25]]
reverse = matrix[::-1]
T = np.transpose(reverse, (1, 0))
print(T)

 

posted @ 2019-07-31 20:25  Stoves  阅读(315)  评论(0编辑  收藏  举报