arr = np.random.randn(5,5)
print(arr)
print(arr[range(0,4)])
[[-0.27366281 0.72093597 0.84652239 -0.6280336 0.12319857]
[-0.6987391 0.26662937 0.16126181 0.61819093 0.6562751 ]
[ 0.3017728 0.22513737 0.14638972 0.38876828 -2.63334874]
[-1.00352935 0.22064535 -0.20035918 0.32413809 -0.66917382]
[ 0.01889059 -1.1518937 -0.72122115 0.72605176 -0.11872566]]
[[-0.27366281 0.72093597 0.84652239 -0.6280336 0.12319857]
[-0.6987391 0.26662937 0.16126181 0.61819093 0.6562751 ]
[ 0.3017728 0.22513737 0.14638972 0.38876828 -2.63334874]
[-1.00352935 0.22064535 -0.20035918 0.32413809 -0.66917382]]
print(list(range(1,2)))
print(arr[range(1,2)])
print(arr[list(range(1,2))])
从这种可以知道 numpy格式自动将range转换为list格式