从数组中提取符合条件的元素 arr = np.arange(10) arr #array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) #设置条件,如:能整除3 condition = np.mod(arr, 3)==0 condition #array([ True, False, False, True, False, False, True, False, False,True]) #np.extract()会把True对应的元素提取出来返回 np.e