numpy.ndarray.shape
ndarray.shape
Tuple of array dimensions.
获得数组维度的 tuple
Notes
May be used to “reshape” the array, as long as this would not require a change in the total number of elements
Examples
>>> x = np.array([1, 2, 3, 4])
>>> x.shape
(4,)
>>> y = np.zeros((2, 3, 4))
>>> y.shape
(2, 3, 4)
>>> y.shape = (3

本文介绍了numpy中ndarray的shape属性,它返回数组的维度元组。shape可用于重塑数组,条件是元素总数不变。文中包含注意事项和实例解析。
最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



