人到中年有点甜
当您使用两对括号寻址数据时,您将执行两个操作,第一个括号从数据中选择一个新数组,第二个括号寻址新数组。In [71]: np.random.seed(2020) ...: fridge = np.random.randint(11, size=(30, 5)) ...: tasty = fridge_items[:,4] > 7 ...: tastyfridge = fridge[tasty,:] In [72]: tastyfridge[:2,:], fridge[tasty][:2,:] Out[72]: (array([[ 8, 10, 9, 3, 7], [ 4, 7, 1, 4, 9]]), array([[ 8, 10, 9, 3, 7], [ 4, 7, 1, 4, 9]]))In [73]: