Learn Python in 7 Days
上QQ阅读APP看书,第一时间看更新

Bitwise operators

Python supports bitwise operations. You might have come across AND, OR, or complementary operations:

The following screenshot illustrates the various usages of bitwise operators:

~x will give -241, which is in 2's complement form due to a signed binary number.