import numpy as np
array = np.array([[1,2,3],[2,3,4]])print(array)print('number of dim:',array.ndim)#维数print('shape:',array.shape)print('size:',array.size)#总共元素的多少
[[1 2 3]
[2 3 4]]
number of dim: 2
shape: (2, 3)
size: 6
import numpy as np
a = np.array([[2,23,4],[7,58,3]],dtype=np.float32)#定义数据类型print(a)print(a.dtype,'\n')
b = np.zeros((3,4))#零矩阵print(b,'\n')
c = np.ones((3,4),dtype=np.int16)print(c,'\n')
d = np.empty((3,4))#空矩阵print(d,'\n')
import numpy as np
a = np.arange(10,20,2)#定义间隔print(a,'\n')
b = np.arange(12).reshape((3,4))#reshape成指定格式矩阵print(b,'\n')
c = np.linspace(1,10,20).reshape((5,4))#定义段数,自动分段print(c,'\n')