Convert integer to fixed length binary string

Mensanator mensanator at aol.com
Thu Jun 11 14:20:58 EDT 2009


On Jun 11, 4:29 am, casebash <walkr... at gmail.com> wrote:
> Sorry, I didn't quite make it clear. The issue isn't about limiting
> the length (as I won't be using integers bigger than this). The
> problem is that sometimes the output is shorter.

This works also:

>>> bin(15)[2:].zfill(32)
'00000000000000000000000000001111'



More information about the Python-list mailing list