Warning: count(): Parameter must be an array or an object that implements Countable in /usr/local/lighthouse/softwares/typecho/usr/plugins/AMP/Action.php on line 388
利用Python将URL中百分号%开头字符串转为中文

利用Python将URL中百分号%开头字符串转为中文

2023-08-16T05:54:00
import urllib.parse as parse

res = parse.quote("中文", encoding="UTF-8")
res2 = parse.unquote("%E4%B8%AD%E6%96%87", encoding="UTF-8")
print(res)  # %E4%B8%AD%E6%96%87
print(res2)  # 中文
当前页面是本站的「Baidu MIP」版。发表评论请点击:完整版 »