Convert base-2 binary number string to int September 8, 2022 by Tarik You use the built-in int() function, and pass it the base of the input number, i.e. 2 for a binary number: >>> int('11111111', 2) 255 Here is documentation for Python 2, and for Python 3.