How can I convert data after processing urllib.urlencode to dict?
urllib.urldecode does not exist.
How can I convert data after processing urllib.urlencode to dict? urllib.urldecode does not exist.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As the docs for
urlencodesay,(In older Python releases, they were in the
cgimodule). So, for example:The obvious difference between the original dictionary
dand the “round-tripped” oned1is that the latter has (single-item, in this case) lists as values — that’s because there is no uniqueness guarantee in query strings, and it may be important to your app to know about what multiple values have been given for each key (that is, the lists won’t always be single-item ones;-).As an alternative:
you can get a sequence of pairs (urlencode accepts such an argument, too — in this case it preserves order, while in the dict case there’s no order to preserve;-). If you know there are no duplicate “keys”, or don’t care if there are, then (as I’ve shown) you can call
dictto get a dictionary with non-list values. In general, however, you do need to consider what you want to do if duplicates are present (Python doesn’t decide that on your behalf;-).