Using Python2.4.5 (don\'t ask!) I want to parse a query string and get a dict in return. Do I have to do it \"manually\" like follows?
>>> qs = \'first=
You have two options:
>>> cgi.parse_qs(qs)
{'second': ['4'], 'third': ['3'], 'first': ['1']}
or
>>> cgi.parse_qsl(qs)
[('first', '1'), ('second', '4'), ('third', '3')]
The values in the dict returned by cgi.parse_qs()
are lists rather than strings, in order to handle the case when the same parameter is specified several times:
>>> qs = 'tags=python&tags=programming'
>>> cgi.parse_qs(qs)
{'tags': ['python', 'programming']}