【笔记】Python3实现URL编解码

前言

Python3实现URL编解码

requests

下载依赖

1
pip3 install requests

URL编码

1
2
3
import requests

requests.utils.quote("未编码的字符串")

URL解码

1
2
3
import requests

requests.utils.unquote("已编码的字符串")

urllib

URL编码

1
2
3
import urllib

urllib.parse.quote("未编码的字符串", 'utf-8')

URL解码

1
2
3
import urllib

urllib.parse.unquote("已编码的字符串", 'utf-8')

完成

参考文献

CSDN——桥路丶