我正在尝试解析来自 API 的响应数据,但我不断收到此错误。
这是我的代码:
import requests
import json
url = "https://ratings.food.gov.uk/OpenDataFiles/FHRS776en-GB.json"
r = requests.get(url)
json_data = r.json()
这是错误
File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 889, in json
return complexjson.loads(
File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 1 column 233384 (char 233383)
我已经确认这是一个有效的 JSON,并且这是一个公共 API,因此我无法控制格式。我怎样才能克服这个错误?
梵蒂冈之花
森林海
相关分类