>>> import numpy as np
>>> a = np.arange(10)
>>> a
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> a = np.arange(10)
>>> a
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> a[:,1]
array([1, 3, 5, 7, 9])
>>> a[:,0]
array([0, 2, 4, 6, 8])
>>> a = np.arange(12)
>>> a = a.reshape(3,2,2)
>>> a
array([[[ 0, 1],
[ 2, 3]],
[[ 4, 5],
[ 6, 7]],
[[ 8, 9],
[10, 11]]])
>>> a[...,1]
array([[ 1, 3],
[ 5, 7],
[ 9, 11]])
>>> a[:,1]
array([[ 2, 3],
[ 6, 7],
[10, 11]])
>>> a[:,:,1]
array([[ 1, 3],
[ 5, 7],
[ 9, 11]])
可以总结如下:"..."表示包含前面所有维度,只对最后一个维度切片;
":"是逐维度切片的,每个维度一个":"