开发者

Why does Python's urlparse.parse_qs() split arguments on semicolon

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 pas开发者_C百科s 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)


';' is equivalent to '&'

W3C recommends that all web servers support semicolon separators in the place of ampersand separators.

So use ',' instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜