我正试图解析来自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,所以我无法控制格式。我怎样才能克服这个错误
问题不在于代码,而在于json
您可以验证jsonhere。第7669行和第7670行各缺少一个
,
你可以用
相关问题 更多 >
编程相关推荐