初始化
a = range(16)
a = np.array(a)
a = a.reshape(4,4)
- a
-
-
[[ 0 1 2 3][ 4 5 6 7][ 8 9 10 11][12 13 14 15]]
-
- 获取a的【0,1,4】行
-
- b = a[ range( 2)+range( 3, 4),:]
-
[[ 0 1 2 3][ 4 5 6 7][12 13 14 15]]
- 获取b的【0,1,4】列
-
- c = b[:, range( 1 )+range(2 , 3)]
-
[[ 0 2][ 4 6][12 14]]