作者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://www.ptt.cc/bbs/Python/M.1493651030.A.9F9.html
→ DavisX: rot90 ? 05/01 23:20
rotated = np.rot90(arr_cipher_grille, 1, (1,0))就可以了. 謝謝你
→ 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
推 cobrasgo: 最快方法就是把螢幕往左90度倒 05/03 18:32
→ angleevil: = = 05/04 14:40