How to print non-printable chars??

Nobody nobody at
Sat Aug 13 07:22:22 CEST 2011

On Sat, 13 Aug 2011 00:59:42 -0400, Julio Cesar Rodriguez Cruz wrote:

> Hi all,
> If I open an .exe file in any text editor I get lot of odd chars,
> what I want is to know how to output those chars if I have the hexadecimal
> code. I found out how to do the reverse process with the quopri module,
> i.e.:
>>>> import quopri
>>>> quopri.encodestring('ñè')
> '=F1=E8=18'
>>>> quopri.decodestring('=F1=E8=18')
> '\xf1\xe8\x18'
> but how to do the reverse? ...gived '\xf1\xe8\x18', print 'ñè'


If you type an expression into the interactive Python interpreter, the
result is converted to a string using repr(); for strings, this converts
8-bit characters to their hexadecimal escape sequences, so that the result
only uses ASCII.

OTOH, the print statement converts values to strings using str(); for
strings, this is an identity operation (i.e. it returns the original
string untouched). Similarly, the .write() method of file objects uses str().

More information about the Python-list mailing list