Convert hex to string

Magnus Lycka lycka at carmen.se
Thu Oct 6 10:56:38 EDT 2005


Java and Swing wrote:
> I have some output stored in a string that looks like..
> 
> 
>>>x
> 
> '\x01\xee\x1eo\xc3+\x8b\x83\xfad\xf6E\xaa\x0ea/I\x96\x83\xf5G\xa3\rQ\xfcH\xee\r'
> 
> 
> According to, http://docs.python.org/lib/typesseq-strings.html, this is
> "Unsigned Hexidecimal (lowercase)".  How can I get this into normal
> Ascii so that I can read it?

What did you expect this string to print? Where did it come from?
Viewed as ASCII it's mainly non-printables, with o, +, d, E, a/I,
G, Q and H stuffed in, but I'm pretty sure it isn't 8 bit text
in any normal encoding. The only reason to suspect that this might
be text after all, is that it ends with a carriage return.

Converting your string to numbers, we get...
1 238 30 111(o) 195 43(+) 139 131 250 100(d) 246 69(E) 170 14 97(a)
47(/) 73(I) 150 131 245 71(G) 163 13 81 (Q) 252 72(H) 238 13.

You can find the definition of ASCII via Google.



More information about the Python-list mailing list