Python笔记:3.1.2.1numpy数组_花式索引

# -*- coding: utf-8 -*-
"""
Created on Sun May 19 15:51:26 2019

@author: User
"""

import numpy as np

b = np.arange(24).reshape(2, 3, 4)
print(b)

print('\n1-------------------\n')
print(b[[[0], [1, 2], [2, 3]]])

print('ix_函数:')
print(b[np.ix_([1, 0], [2, 1], [0, 3, 2])])

运行:

[[[ 0  1  2  3]
  [ 4  5  6  7]
  [ 8  9 10 11]]

 [[12 13 14 15]
  [16 17 18 19]
  [20 21 22 23]]]

1-------------------

[ 6 11]
ix_函数:
[[[20 23 22]
  [16 19 18]]

 [[ 8 11 10]
  [ 4  7  6]]]

你可能感兴趣的:(python学习)