Problem: neither urllib2.quote nor urllib.quote encode the unicode strings arguments

Miki miki.tebeka at gmail.com
Sun Oct 5 06:16:27 EDT 2008


Hello,

> things like urllib.quote(u"пиво Müller ") fail with error message:
> <type 'exceptions.KeyError'>: u'\u043f'
>
> Similarly with urllib2.
>
> Anyone got a hint?? I need it to form the URI containing non-ascii chars
.

n = u"пиво Müller "
print urllib.quote(n.encode("utf-8")) -> %D0%BF%D0%B8%D0%B2%D0%BE%20M
%C3%BCller

HTH,
--
Miki <miki.tebeka at gmail.com>
http://pythonwise.blogspot.com



More information about the Python-list mailing list