输入数组中整数的二进制按位与(and)运算由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)
其输出如下-
Binary equivalents of 13 and 17: 0b1101 0b10001 Bitwise AND of 13 and 17: 1