binary representaion of a number

David Broadwell dbroadwell at mindspring.com
Sun Aug 20 22:48:12 EDT 2000


Deja and the faqts and the docs, haven't quite yeilded what i am looking
for. And to me it sounds very simple, so perhaps i am missing something.

I have numbers, that i have pulled in as strings in a file, converted
them to the actuall object. Now, how do i display or print it as a
binary string.

>>> thestring ='3c0f1001'
>>> i = string.atoi(thestring,16)
>>> print i
1007620097
>>> hex(i)
'0x3c0f1001'
>>> oct(i)
'07403610001'

here is what i am looking for:
>>> bin(i)
'111100000011110001000000000001'

Help - ideas?



More information about the Python-list mailing list