import numpy as np
data1 = np.array([1,2,3,4,5])
print(data1)
data2 = np.array([[1,2],
[3,4]])
print(data2)
#维度
print(data1.shape,data2.shape)
# zero ones
print(np.zeros([2,3]))
print(np.ones([2,2]))
# 改查
data2[1,0] = 5
print(data2)
print(data2[1,1])
# 基本运算
data3 = np.ones([2,3])
print(data3*2)#对应相乘
print(data3/3)
print(data3+2)
# 矩阵-*
data4 = np.array([[1,2,3],[4,5,6]])
print(data3-data4)
print(data3*data4)
Numpy模块简单应用
最新推荐文章于 2022-12-05 13:54:25 发布