换句话说,我想做点什么
A[[-1, 0, 1], [2, 3, 4]] += np.ones((3, 3))
代替
A[-1:3, 2:5] += np.ones((1, 3)) A[0:2, 2:5] += np.ones((2, 3))
python numpy
numpy ×1
python ×1