Two dimensional numpy arrays are indexed using a[i,j]
(not a[i][j]
), but you can use the same slicing notation with numpy arrays and matrices as you can with ordinary matrices in python (just put them in a single []
):
>>> from numpy import array
>>> a = array([[1,2,3],[3,4,5],[4,5,6]])
>>> a[:,1:]
array([[2, 3],
[4, 5],
[5, 6]])
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…