a = 0b1101 b = 0b1010 print(a, b) # 13 10 # 与 print(bin(a & b)) # 0b1000 # 或 print(bin(a | b)) # 0b1111 # 异或 print(bin(a ^ b)) # 0b0111, 位不同的为1, 相同的为0 # 非 print(bin(~a)) # -0b1110, -(a+1) # 左移 print(bin(a << 1)) # 0b11010 # 右移 print(bin(a >> 1)) # 0b110
标签:bin,10,入门,Python,print,运算 From: https://www.cnblogs.com/sailJs/p/17567379.html