[問題] 如何將numpy創造的二維陣列的值, 向右90度旋轉
大家好,我使用了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://www.ptt.cc/bbs/Python/M.1493651030.A.9F9.html
→
05/01 23:20, , 1F
05/01 23:20, 1F
rotated = np.rot90(arr_cipher_grille, 1, (1,0))就可以了. 謝謝你
→
05/02 02:01, , 2F
05/02 02:01, 2F
後來發現要[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
推
05/03 18:32, , 3F
05/03 18:32, 3F
→
05/04 14:40, , 4F
05/04 14:40, 4F