作者angleevil (朦胧寻光)
看板Python
标题[问题] 如何将numpy创造的二维阵列的值, 向右90度旋转
时间Mon May 1 23:03:44 2017
大家好,我使用了numpy.vstack来创造一个二维阵列.
但是想要向右90度旋转此阵列的值.
变成下面这样,请问numpy有提供此函式吗?? inv or .T都不是我想要的方式.也有试过rot90.但好像都不行.
.X.X
..X.
X..X
....
import numpy as np
from numpy.linalg import inv
def recall_password(cipher_grille):
list_cipher_grille = [list(item) for item in cipher_grille]
arr_cipher_grille = np.vstack(list_cipher_grille[B)
#向右转值
return ""
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
recall_password(
('X...',
'..X.',
'X..X',
'....'))
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 1.171.61.185
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1493651030.A.9F9.html
1F:→ DavisX: rot90 ? 05/01 23:20
rotated = np.rot90(arr_cipher_grille, 1, (1,0))就可以了. 谢谢你
2F:→ a75468: 你的输入矩阵x的数量跟你想要的矩阵x数量不一样 05/02 02:01
後来发现要[list(item) for item in cipher_grille], 先把每个元素用出来. 在塞入np.vstack.
才是4*4.
※ 编辑: angleevil (1.171.61.185), 05/02/2017 21:22:52
※ 编辑: angleevil (1.171.61.185), 05/02/2017 21:29:43
※ 编辑: angleevil (1.171.61.185), 05/02/2017 21:54:07
※ 编辑: angleevil (1.171.61.185), 05/02/2017 22:10:26
3F:推 cobrasgo: 最快方法就是把萤幕往左90度倒 05/03 18:32
4F:→ angleevil: = = 05/04 14:40