现在有个二维数组:data=[0,1,2,3],[0,1,2,3],[0,1,2,3],[0,1,2,3],每一行都是[0,1,2,3],要求顺时针旋转90度,变成每一列都是[0,1,2,3]。
#首先生成一维数组的语句是: row=[i for i in range(6)] print(row) #运行结果: #[0, 1, 2, 3, 4, 5] #生成二维数组的语句是: data=[[i for i in range(4)] for k in range(4)] for j in data: print(j) ‘‘‘ 相当于是把一维数组的整体作为上面的i 运行结果是: [0, 1, 2, 3] [0, 1, 2, 3] [0, 1, 2, 3] [0, 1, 2, 3] ‘‘‘
原文地址:https://www.cnblogs.com/yibeimingyue/p/9329358.html
时间: 2024-12-09 16:48:07