import numpy as np
# numpy 基本属性
array = np.array([[1,2,3],[4,5,6]])
print(array)
print('number of dim:', array.ndim)
print('shape:',array.shape)
print('size:',array.size)
[[1 2 3]
[4 5 6]]
('number of dim:', 2)
('shape:', (2, 3))
('size:', 6)
#创建array
import numpy as np
# 没有逗号分隔
array = np.array([[1,2,3],[4,5,6]],dtype = np.int)
print array.dtype
print np.zeros((3,4))
print np.ones((3,4),dtype = np.int16)
print np.empty((3,4))
print np.arange(10,20,2)
print np.arange(12).reshape(3,4)
print np.linspace(1,10,5)
print np.linspace(1,10,6).reshape(2,3)
int64
[[ 0. 0. 0. 0.]
[ 0. 0. 0. 0.]
[ 0. 0. 0. 0.]]
[[1 1 1 1]
[1 1 1 1]
[1 1 1 1]]
[[ 0.00000000e+000 4.94065646e-324 9.88131292e-324 1.48219694e-323]
[ 1.97626258e-323 2.47032823e-323 2.96439388e-323 3.45845952e-323]
[ 3.95252517e-323 4.44659081e-323 4.94065646e-323 5.43472210e-323]]