例题2.30

DENWOSHUABAZONGSHI / 2024-11-11 / 原文

例题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 = 1, keepdims = True)
#print(c1)
print(c2.shape, c3.shape)