Convert integer to fixed length binary string

casebash walkraft at gmail.com
Thu Jun 11 05:28:16 EDT 2009


Hi,

I know the bin function converts an int into a binary string.
Unfortunately, I need to know the length of the binary string when it
is being read in and len(bin(x)) depends on x. Is there any way to
limit it to 4 bytes?

Thanks for your assistance,

Chris



More information about the Python-list mailing list