Bitwise Operations : Bitwise Operators « Operator « Python Tutorial






x = 1                # 0001
print x << 2         # Shift left 2 bits: 0100
print x | 2          # bitwise OR: 0011
print x & 1          # bitwise AND: 0001








4.2.Bitwise Operators
4.2.1.Integer Type Bitwise Operators
4.2.2.Bitwise Operations