2015-09-27 34 views
1

我在字典中存儲numpy矩陣。但是,當我試圖找出矩陣的形狀時,它會失敗:Python:無法在字典中檢索numpy矩陣的形狀

dict_ = {'one' : np.zeros(shape=(5, 4)), 'two' : np.zeros(shape=(2, 5))} 

print type(dict_['one']) 
<type 'numpy.ndarray'> 

print dict_['one'].shape() 
TypeError: 'tuple' object is not callable 

我在這裏丟失了什麼?

回答

1

屬性shape是不可調用的,你需要使用它如下:

print dict_['one'].shape 
+0

哦,親愛的上帝,我怎麼能錯過呢?也許需要休息一下。 謝謝反正 –

+0

@DarshanChaudhary歡迎,如果它是有用的,你可以通過投票和接受答案這個社區說。 – Kasramvd

+0

在一段時間過去之前不能接受。當我被允許時會做。 –