python数字搜索的实例
import numpy as np
x= np.array([[30,40,0],[0,20,10],[50,0,60]])
print(x.shape)
xx=x[:,0:2]
print(xx)
y = np.where(xx==[30000,4000])
print(len(x[y]))
关键是利用where
import numpy as np
x= np.array([[30,40,0],[0,20,10],[50,0,60]])
print(x.shape)
xx=x[:,0:2]
print(xx)
y = np.where(xx==[30000,4000])
print(len(x[y]))
关键是利用where