在线url网址编码解码PythonURL地址中汉字的编码转换Python3 编码 解码 ⽰例
""" utf8 编码"""
quest import quote, unquote
url1 = "www.baidu/s?wd=百度"
# utf8编码,指定安全字符
ret1 = quote(url1, safe=";/?:@&=+$,", encoding="utf-8")
print(ret1)
"""gbk编码"""
quest import quote, unquote
url2 = "www.baidu/s?wd=百度"
ret2 = quote(url2, encoding="gbk")
print(ret2)
"""解码"""
quest import quote, unquote
url3 = 'www.baidu/s?wd=%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0'
ret3 = unquote(url3, encoding='utf-8')
print(ret3)
# www.baidu/s?wd=机器学习
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论