阅读量:134
在Python中,可以使用urllib库中的quote()函数来进行URL编码,示例如下:
import urllib.parse
url = "https://www.example.com/?name=张三&age=20"
encoded_url = urllib.parse.quote(url)
print(encoded_url)
这样就可以将URL中的中文字符和特殊字符进行编码,输出结果为:
https://www.example.com/?name=张三&age=20