- 摘要:code過程中有將urlencode及urldecode的需求,接下來介紹在python3中如何將urlencode及urldecode
- 函數
urlencode:
urllib.parse.quote(string, safe='/', encoding=None, errors=None)
urldecode:
urllib.parse.unquote(string, encoding='utf-8', errors='replace')
- 示例驗證
import urllib.parse test = "永遠有多遠" print (test) # urlencode test01 = urllib.parse.quote(test) print(test) #urldecode print(urllib.parse.unquote(new))