2017-09-14 148 views

回答

2
np.flatnonzero((x == y).all(1)) 
# array([0, 2]) 

或:

np.nonzero((x == y).all(1))[0] 

或:

np.where((x == y).all(1))[0] 
0

这适用于每对numpy阵列,如果长度相同:

matches = [i for i in range(len(x)) if x[i].tolist()==y[i].tolist()]