W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
python_numpy_array_filter_2.py:
import numpy as np arr = np.array([61, 62, 63, 64, 65]) # Create an empty list filter_arr = [] # go through each element in arr for element in arr: # if the element is higher than 62, set the value to True, otherwise False: if element > 62: filter_arr.append(True) else: filter_arr.append(False) newarr = arr[filter_arr] print(filter_arr) print(newarr)