[Tutor] How can I convert a bin string to a hex string?

rafael.sousa rafael.sousa at netcabo.pt
Thu Oct 9 13:25:18 EDT 2003


Such as the binary contents of a jpeg image?
 
I'm writing the code to dynamically create a RTF (Rich Text Format) document. In order to insert a picture, it's recommended in the specification that its contents are written in hex.
 
I read the binary content to a regular python string, but then I would need to convert it to another string, this time in hex (which would naturally have the double of the length of the original bin string).
 
Can anyone help?
 
Thanks in advance!



More information about the Tutor mailing list