【发布时间】:2017-12-28 22:14:40
【问题描述】:
我正在使用 requests 库使用 python3 查询 Github 的 Jobs API,但在解析响应时遇到错误。
图书馆:http://docs.python-requests.org/en/latest/
代码:
import requests
import json
url = 'https://jobs.github.com/positions.json?'
response = requests.get(url)
print(response.json())
错误:
UnicodeEncodeError: 'ascii' 编解码器无法对字符 '\u2019' 进行编码 位置 321:序数不在范围内(128)
过去在 Ruby 中使用过这个 API,我从来没有遇到过这个问题。
我也尝试将其转换为字典,但结果相同。
还有其他关于UnicodeEncodeError 的问题(主要是回复:打开文件),但我不熟悉 Python,也没有发现它们有帮助。
【问题讨论】:
标签: python-3.x unicode python-requests