Tag Archives: Python 3 urlcode

Python 3: URLEncode and urlcode

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))