>import numpy as np
>a = np.arange(15).reshape(3, 5)
([[ 0, 1, 2, 3, 4],
[ 5, 6, 7, 8, 9],
[10, 11, 12, 13, 14]])
> a.shape
(3, 5)
> a.ndim
2 /// how to calculate it for any narray
答案 0 :(得分:1)
ndim
与len(a.shape)
在您的情况下,您有2个尺寸,第一个尺寸为3,第二个尺寸为5