numpy.ma.shape#
- ma.shape(obj)[原始碼]#
傳回陣列的形狀。
- 參數:
- aarray_like
輸入陣列。
- 回傳值:
- shape整數元組
形狀元組的元素給出對應陣列維度的長度。
另請參閱
len
len(a)
等效於np.shape(a)[0]
,適用於維度N>=1
的 N 維陣列。ndarray.shape
等效的陣列方法。
範例
>>> import numpy as np >>> np.shape(np.eye(3)) (3, 3) >>> np.shape([[1, 3]]) (1, 2) >>> np.shape([0]) (1,) >>> np.shape(0) ()
>>> a = np.array([(1, 2), (3, 4), (5, 6)], ... dtype=[('x', 'i4'), ('y', 'i4')]) >>> np.shape(a) (3,) >>> a.shape (3,)