NumPy 二进制位与运算符 在输入数组中的整数的二进制表示的对应位上计算按位与操作,可以使用np.bitwise_and()函数。 示例 import numpy as np print 'Binary equivalents of 13 and 17:' a,b = 13,17 print bin(a), bin(b) print '\n' print 'Bitwise AND of 13 and 17:' print np.bitwise_and(13, 17) PythonCopy 其输出如下: Binary equivalents of 13 and 17: 0b1101 0b10001 Bitwise AND of 13 and 17: 1 PythonCopy 你可以按照以下方式验证输出。考虑以下按位与的真值表。