Abstract:There is a need for urlencode and urldecode in the process of code, next, how to urlencode and urldecode in python3
Function
urlencode:
urllib.parse.quote(string, safe=’/’, encoding=None, errors=None)
urldecode:
urllib.parse.unquote(string, encoding=’utf-8′, errors=’replace’)
Example
import urllib.parse
test = "hello world"
print (test)
# urlencode
test01 = urllib.parse.quote(test)
print(test)
#urldecode
print(urllib.parse.unquote(new))
Similar Posts:
- Summary of common functions of urllib.parse in Python 3
- Differences of urllib, urllib2, httplib and httplib2 libraries in Python
- Transcoding of system.web.httputility.urlencode in C #
- TypeError: the JSON object must be str, not ‘bytes’
- Go build cannot find package Error [How to Solve]
- [Solved] HTTP Error 301: The HTTP server returned a redirect error that would lead to an infinite loop.
- ModuleNotFoundError No module named urllib2
- [Solved] Python3.7 Install urllib.parse[UNK]json[UNK]re
- curl HTTP Error 400. The request is badly formed.
- No module named ‘urllib.request’; ‘urllib’ is not a package