Can string formatting be used to convert an integer to its binary form ?

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Thu Sep 28 11:00:15 EDT 2006


Mirco Wahab:
> But where is the %b in Python?

Python doesn't have that. You can convert the number to a hex, and then
map the hex digitds to binary strings using a dictionary, like this:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440528

Bye,
bearophile




More information about the Python-list mailing list