python3编码问题:‘ascii‘ codec can‘t encode characters in position
python3支持编码格式utf-8,所以正常情况下代码中包含中文不会出现上述问题
如果显示错误,可能是因为代码中包含不支持中文的特殊部分
比如最近遇到的网站url,需要进行转义
直接输入下文url会显示错误
url = 'https://api.map.baidu.com/place/v2/search?query=ATM机\
&tag=银行®ion=北京&output=json'
response = urllib.request.urlopen(url)
原创
2022-05-19 11:33:07 ·
1466 阅读 ·
0 评论