in Python> = 2.6 s bin():
asd = bin(123) # => '0b1111011'
To remove a lead 0b, you can simply take a substring bin(123)[2:].
bin (x)
Convert an integer to a binary string. The result is a valid Python expression. If xnot a Python int object, it must define a method __index__()that returns an integer.
New in version 2.6.
source
share