In Python's urlparse, you can use urlparse to parse the URL, and then parse_qsl to parse the query.
I want to remove a query (name, value) pair, and then reconstruct the URL.
There is a urlunparse method, but no unparse_qsl method.
What is the correct way to reconstruct the query from the qsl list?
The function urllib.urlencode is appropriate.
>>> urlparse.parse_qsl('q=stackoverflow')
[('q', 'stackoverflow')]
>>> urllib.urlencode(urlparse.parse_qsl('q=stackoverflow'))
'q=stackoverflow'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With