import requests url='https://kyfw.12306.cn/otn/leftTicket/queryO?leftTicketDTO.train_date=2020-02-12&leftTicketDTO.from_station=WXH&leftTicketDTO.to_station=SZH&purpose_codes=ADULT' response = requests.get(url) result = response.json() result = result['data']['result'] print(result)
报错信息为
Traceback (most recent call last):
File "<ipython-input-37-d25573701c55>", line 1, in <module>
runfile('C:/Users/wangx/Desktop/14/check tickets/untitled4.py', wdir='C:/Users/wangx/Desktop/14/check tickets')
File "C:\Users\wangx\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 786, in runfile
execfile(filename, namespace)
File "C:\Users\wangx\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/wangx/Desktop/14/check tickets/untitled4.py", line 12, in <module>
result = response.json()
File "C:\Users\wangx\Anaconda3\lib\site-packages\requests\models.py", line 897, in json
return complexjson.loads(self.text, **kwargs)
File "C:\Users\wangx\Anaconda3\lib\json\__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "C:\Users\wangx\Anaconda3\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\wangx\Anaconda3\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
JSONDecodeError: Expecting value