numpy.ma.shape#
- ma.shape(obj)[source]#
返回数组的形状。
- 参数:
- aarray_like
输入数组。
- 返回:
- shapetuple of ints
形状元组的元素表示相应数组维度的长度。
另请参阅
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,)