且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何检查数组是否在Python中的另一个数组中

更新时间:2022-10-31 23:06:04

您可以这样做:

([0, 40] == a).all(1).any()

第一步是计算匹配位置的2D布尔数组.然后,找到所有元素都为真的行.然后检查是否有任何行完全匹配.

The first step is to compute a 2D boolean array of where the matches are. Then you find the rows where all elements are true. Then you check if any rows are fully matching.