请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

和老师的代码一样,报错了,怎么解决呢?

C:\Users\Anker\Desktop>python demo.py
Traceback (most recent call last):
File “demo.py”, line 42, in
print (run_main())
File “demo.py”, line 39, in run_main
res=send_post(url,data)
File “demo.py”, line 12, in send_post
res=requests.post(url=url,data=data).json()
File “C:\Program Files\Python37\lib\site-packages\requests\models.py”, line 897, in json
return complexjson.loads(self.text, **kwargs)
File “C:\Program Files\Python37\lib\json_init_.py”, line 348, in loads
return _default_decoder.decode(s)
File “C:\Program Files\Python37\lib\json\decoder.py”, line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “C:\Program Files\Python37\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)

正在回答

1回答

Mushishi 2019-03-27 22:38:46

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)报错说的是json解析失败,说明你接口返回的不是json格式。你把你res=requests.post(url=url,data=data).json()这个替换成:res=requests.post(url=url,data=data).text。去打印看一下你接口返回的是html

0 回复 有任何疑惑可以回复我~
  • 提问者 gp0102 #1
    非常感谢!
    回复 有任何疑惑可以回复我~ 2019-03-27 23:29:47
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信