您也可以单独传递您的第一个元组以获得感兴趣的切片,然后将其分别编入索引:
from numpy.random import rand
big_array=rand(3,3,4,5)
chosen_slice = (2,2)
>>> big_array[ chosen_slice ]
array([[ 0.96281602, 0.38296561, 0.59362615, 0.74032818, 0.88169483],
[ 0.54893771, 0.33640089, 0.53352849, 0.75534718, 0.38815883],
[ 0.85247424, 0.9441886 , 0.74682007, 0.87371017, 0.68644639],
[ 0.52858188, 0.74717948, 0.76120181, 0.08314177, 0.99557654]])
>>> chosen_part = (1,1)
>>> big_array[ chosen_slice ][ chosen_part ]
0.33640088565877657
对于某些用户而言,这可能稍微更具可读性,但除此之外,我倾向于mgilson的解决方案.