size() 和shape() 是Numpy中才有的函数。 size 用来计算数组和矩阵中所有元素的个数 a = np.array([[1, 2, 3], [4, 5, 6]]) np.size(a) # 返回值为6 np.size(a,1) # 返回值为3 shape 用来计算矩阵每维的大小 np.shape(a) # 返回值为(2, 3)