decode a url

Andreas Kuntzagk andreas.kuntzagk at mdc-berlin.de
Tue Aug 19 10:25:02 CEST 2003


On Tue, 19 Aug 2003 09:37:20 +0200, Invalid User wrote:

> Is there a function/module to decode url's in python? So far, I have come
> across "urllib.encode" for encoding, which the opposite of I am looking
> for.
Quick search on google:
http://groups.google.com/groups?q=group%3Acomp.lang.python+urldecode
reveals:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&selm=jjb5-390295.16085712062002%40newsstand.cit.cornell.edu
which proposes cgi.parse_qsl
test:
>>> import cgi
>>> import urllib
>>> cgi.parse_qsl(urllib.urlencode({"test1":1,"test2":3}))
[('test1', '1'), ('test2', '3')]
>>> dict(_)
{'test1': '1', 'test2': '3'}

So seems to work

Andreas




More information about the Python-list mailing list