a=[1,2,3,4,5,6,7,8]
a=np.array(a)
b=np.where((a>2)&(a<6))
print(b)
#(array([2, 3, 4], dtype=int64),)
一定要将a转化为数组,否则会报错: ‘>’ not supported between instances of ‘list’ and ‘int’
a=[1,2,3,4,5,6,7,8]
a=np.array(a)
b=np.where((a>2)&(a<6))
print(b)
#(array([2, 3, 4], dtype=int64),)
一定要将a转化为数组,否则会报错: ‘>’ not supported between instances of ‘list’ and ‘int’