'{0:08b}'.format(number_to_transform)
Explanation:
{} |
places variable into a string |
0 |
takes the variable at argument position 0 |
: |
adds formatting options for this variable (otherwise it would represent decimal 6) |
08 |
formats the number to eight digits zero-padded on the left |
b |
converts the number to its binary representation |