[Tutor] How to convert hex representation of char? (Challenge part 8)
Alan G
alan.gauld at freenet.co.uk
Wed May 18 20:46:15 CEST 2005
> onepart and anotherpart contain many hex representations of
nonprintable
> characters, like '\x14'. But I can't manage to convert those to the
> actual nonprintable characters. Any hints on how to do this?
'\x14' is the actual non printable charactewrs. If it were printable
you
would see its printed representation, because it isn't Pyhon showsw
you
the hex code as an escaped character but it is the character.
You can get the numeric value using ord just as you would any other
character:
>>> print ord('\x14')
20
>>> print ord{'Q'}
81
so '\x14' is the character, it should just work...
Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauldHTH,
More information about the Tutor
mailing list