How to do integers to binary lists and back

Ian Kelly ian.g.kelly at gmail.com
Thu May 21 18:38:30 EDT 2015


On Thu, May 21, 2015 at 4:31 PM, Ben Finney <ben+python at benfinney.id.au> wrote:
>>>> "{foo:d}".format(foo=foo)
> '4567'
>>>> "{foo:b}".format(foo=foo)
> '1000111010111'

Which since there's nothing else in the format string can be simplified to:

>>> format(foo, "b")
'1000111010111'



More information about the Python-list mailing list