how to get character hex number?

Mark Lawrence breamoreboy at yahoo.co.uk
Sat Sep 1 04:49:39 EDT 2012


On 01/09/2012 04:50, Tim Chase wrote:
>
> Well, in 3.1.3 at least, using the u"..." notation dies on me with
> an invalid syntax.  However, as Ian suggests, you can do
>
>    my_str = "english"
>    "".join("%02x" % c for c in my_str.encode("ascii"))
>
> or whatever other encoding you want instead of "ascii".
>
> -tkc
>
>

The u"..." notation has been reintroducd for Python 3.3 see 
http://docs.python.org/dev/whatsnew/3.3.html#pep-414-explicit-unicode-literals

-- 
Cheers.

Mark Lawrence.




More information about the Python-list mailing list