Convert base-2 binary number string to int
Another way to do this is by using the
from bitstring import BitArray b = BitArray(bin='11111111') b.uint255
Note that the unsigned integer is different from the signed integer:
bitstring module isn't a requirement, but it has lots of performant methods for turning input into and from bits into other forms, as well as manipulating them.