JavaScript | Python
-----------------------------------
encodeURI(str) | urllib.parse.quote(str, safe="~@#$&()*!+=:;,?/\"');
-----------------------------------
encodeURIComponent(str) | urllib.parse.quote(str, safe="~()*!\"')
On Python 3.7+ you can remove ~ from safe=.