【发布时间】:2021-05-26 14:46:08
【问题描述】:
我是 python 和一般编程的新手,所以请耐心等待..
所以我从 API 中提取了一个请求,但是当我尝试转换为 json 时,我收到以下错误
File "Transport Finder.py", line 44, in <module>
routejson = route.json()
File "C:\ProgramData\Anaconda3\lib\site-packages\requests\models.py", line 897, in json
return complexjson.loads(self.text, **kwargs)
File "C:\ProgramData\Anaconda3\lib\json\__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "C:\ProgramData\Anaconda3\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\ProgramData\Anaconda3\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
这是我目前正在使用的代码,以前可以使用,但我刚刚回到它,现在出现此错误。
route = requests.get(f'http://router.project-osrm.org/route/v1/driving/{StartLL};{EndLL}?alternatives=false&annotations=nodes')
routejson = route.json()
【问题讨论】:
标签: python json python-requests