This language bar is your friend. Select your favorite languages!
Edit summary for version 30 :

Version 29

Version 30

Idiom #76 Binary digits from an integer

Create the string s of integer x written in base 2.

E.g. 13 -> "1101"

Idiom #76 Binary digits from an integer

Create the string s of integer x written in base 2.

E.g. 13 -> "1101"

Code
x = 0xFF
s = '{:b}'.format(x)
Doc URL
https://docs.python.org/3/library/string.html#formatstrings
Origin
https://docs.python.org/3/library/string.html#formatstrings