检查一对值是否在2D数组python中 [英] checking if a pair of value is inside a 2D array python
本文介绍了检查一对值是否在2D数组python中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
给出一个数组 arr
定义如下
arr = np.arange(4).reshape((2,2))
我想检查一对例如,值[0,1]的值位于我的数组之内
I want to check if a pair of value [0,1] for exemple is inside my array
我尝试了np.isin(),但是它将值对视为两个单独的值。有人知道解决此问题的方法吗?
I tried np.isin() but it consider the pair of value as two individual value. anyone knows a way to fix this?
推荐答案
您可以简单地运行
print([0,1] in arr)
查看第一级循环中是否存在 [0,1]
。在您提供的示例中,它应该返回 True
to see if [0,1]
exists in the first level loop. It should return True
in the example you have provided
这篇关于检查一对值是否在2D数组python中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文