例2.30矩阵元素求和示例
import numpy as np
a = np.array([[0,3,4],[1,6,4]])
b = a.sum()
c1 = sum(a)
c2 = np.sum(a,axis = 0)
c3 = np.sum(a,axis = 0,keepdims = True)
print(c2.shape,c3.shape)
print('学号:3008')
结果如下图
import numpy as np
a = np.array([[0,3,4],[1,6,4]])
b = a.sum()
c1 = sum(a)
c2 = np.sum(a,axis = 0)
c3 = np.sum(a,axis = 0,keepdims = True)
print(c2.shape,c3.shape)
print('学号:3008')
结果如下图