hex question

Emile van Sebille emile at fenx.com
Fri Jun 25 16:35:40 EDT 2010


On 6/25/2010 1:20 PM Sneaky Wombat said...
> Why is python turning \x0a into a \n ?
>
> In [120]: h='\x0a\xa8\x19\x0b'
>
> In [121]: h
> Out[121]: '\n\xa8\x19\x0b'
>
>
> I don't want this to happen, can I prevent it?
>


It's not happening.  What you're seeing is the representation of the 
four bytes, and \x0a _is_ \n and python displays the common form to 
assist interpretation.

What you can do is write a display function to suit your needs if it 
makes a difference.

\x48\x54\x48\x2c

Emile




More information about the Python-list mailing list