📌  相关文章
📜  检查 numpy 数组中是否有任何值重叠 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:02.884000             🧑  作者: Mango

代码示例1
import numpy as np
array_1 = np.array(((1, 2, 3), (4, 5, 6), (7, 8, 9)))
array_2 = np.array(((3, 1, 2), (5, 4, 6), (7, 9, 8)))
#In this example, array_2 does have some of the same elements(i.e. the 6s and 7s are in the same place)
#This means that when we check if any of their elements are the same, we will get True.
print(np.any(array_1 == array_2))
#output is True
print(np.all(array_1 == array_2))
#output is False