[Tutor] How can I convert hex string to binary string?

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Tue, 2 Apr 2002 23:44:28 -0800 (PST)


On Wed, 3 Apr 2002, Ares Liu wrote:

> such as '0A0B' to '0000101000001011' ?
> is there any function or module?

Not directly.  There is a function called int() that can convert something
like the string '0A0B' into an integer:

###
>>> int('0A0B', 16)
2571
###

So your problem can be simplified to figuring out how to convert a regular
integer into a binary string.


If you have more questions, please feel free to bring them up to Tutor.
Good luck!