# encoding:utf-8

 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)
# 全零矩阵和全一矩阵
print(np.zeros([2,3]), 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)
print(data3-2)
# 矩阵+和*
data4 = np.array([[1, 2, 3], [4, 5, 6]])
print(data3+data4)
print(data3*data4)
05-25 19:32