[Tutor] urllib.urlencode and unicode strings
Jon Crump
jjcrump at myuw.net
Fri May 18 21:13:43 CEST 2007
Kent,
Thanks so much. It's easy when you know how. Now that I know, I only need
the encode('utf-8') step since geopy does the urlencode step.
On Thu, 17 May 2007, Kent Johnson wrote:
> It's two steps. First convert to utf-8, then urlencode:
>>>> c = u'\xe2'
>>>> c
> u'\xe2'
>>>> c.encode('utf-8')
> '\xc3\xa2'
>>>> import urllib
>>>> urllib.quote(c.encode('utf-8'))
> '%C3%A2'
>
> Kent
More information about the Tutor
mailing list