urlencode() for RFC 3986

Viewed 2919

Python has a terrific urlencode() function which encodes a dict via RFC 1738 (Plus encoding):

>>> urllib.parse.urlencode({'site':'Stack Overflow','Coder':'Jeff Atwood'})
'Coder=Jeff+Atwood&site=Stack+Overflow'

I cannot find a replacement that uses RFC 3986 (Percent encoding), even though the fine manual states the following:

RFC 3986 - Uniform Resource Identifiers
This is the current standard (STD66). Any changes to urllib.parse module should conform to this.

This would be the expected output:

>>> urllib.parse.urlencode({'site':'Stack Overflow','Coder':'Jeff Atwood'})
'Coder=Jeff%20Atwood&site=Stack%20Overflow'

Of course I could roll my own, but I find it surprising that I can find no such Python function built in. Is there such a Python function that I'm just not finding?

2 Answers
Related