pyhton对url编码
#1.url中特殊字符及汉字的转换:使用函数quote
from urllib.parse import quote
name = ['#', '%', '^', '&', '你好']
for i in name:
i = quote(i, 'utf-8')
print(i)
输出如下:
%23
%25
%5E
%26
%E4%BD%A0%E5%A5%BD
为什么要进行url编码,参考一下两篇文章中的内容:
https://www.sohu.com/a/362162375_120133651?scm=1002.44003c.fe0183.PC_ARTICLE_REC
https://www.cnblogs.com/tfxz/p/12621478.html
https://www.cnblogs.com/monoyi/archive/2013/01/21/code.html