python_numpy库_ndarray的属性

目录

1、ndim(维度)

2、shape(形状)

3、size(总长度)

4、dtype(元素类型)


1、ndim(维度)
n = np.random.rand(3,4)
print(n)
w = n.ndim
print(w)
2、shape(形状)

*三个数字分别表示各个维度的长度

n = np.random.rand(3,4)
print(n)
w = n.ndim
print(w)
x = n.shape
print(x)
3、size(总长度)

*即:行和乘列和

n = np.random.rand(3,4)
print(n)
w = n.ndim
print(w)
x = n.shape
print(x)
c = n.size
print(c)
4、dtype(元素类型)
n = np.random.rand(3,4)
print(n)
w = n.ndim
print(w)
x = n.shape
print(x)
c = n.size
print(c)
l = n.dtype
print(l)

你可能感兴趣的:(python,numpy,开发语言)