I'm writing a test script in Python to check the output of my PHP application and I've got a problem with Python's urlparse.parse_qs()
function. GET string delimiter (AFAIK) is an ampersand. The function (as I understand) is supposed to split a GET string into Python dictionary, so that the output for count=2&offset=5&userID=1
should be:
{'count': ['2'], 'userID': ['1'], 'offset': ['5']}
And it is. But when I try to pass CSV in GET (separated with semicolons) such as ids=5;15;3
, I get the following:
[('3', ''), ('15', ''), ('ids', '5')]
I think the valid output should look like this:
{'ids': ['5;15;3']}
What am I doing wrong? The line looks like this:
args = urlparse.parse_qs(sys.argv[2], keep_blank_values=True)
This answer is obsolete. See comments.
So use ',' instead.