URL query parameters to dict python
问题 Is there a way to parse a URL (with some python library) and return a python dictionary with the keys and values of a query parameters part of the URL? For example: url = \"http://www.example.org/default.html?ct=32&op=92&item=98\" expected return: {\'ct\':32, \'op\':92, \'item\':98} 回答1: Use the urllib.parse library: >>> from urllib import parse >>> url = "http://www.example.org/default.html?ct=32&op=92&item=98" >>> parse.urlsplit(url) SplitResult(scheme='http', netloc='www.example.org', path