Python                                                          Home : www.sharetechnote.com

 

 

 

 

Python - Bitwise Operators

 

NOTE : All the examples in this page are written in Python 3.x. It may not work if you use Pyton 2.x

 

Operation

Python

Comments

AND

&

Bitwise AND (e.g, x & y)

OR

|

Bitwise AND (e.g, x | y)
NOT

~

Bitwise Complement (e.g, ~x)

XOR

^

Bitwise Exclusive OR (e.g, x ^ y)
SHIFT RIGHT

>>

x >> y
SHIFT LEFT

<<

x << y