numpy.dtype.ndim#

属性

dtype.ndim#

如果此数据类型描述的是一个子数组,则返回该子数组的维度数;否则返回 0

示例

>>> import numpy as np
>>> x = np.dtype(float)
>>> x.ndim
0
>>> x = np.dtype((float, 8))
>>> x.ndim
1
>>> x = np.dtype(('i4', (3, 4)))
>>> x.ndim
2