带有request.post的JSONDecodeError

时间:2018-07-09 19:39:27

标签: python post flask request

我正在使用Python-3.5,并尝试使用flask部署模型,我已导入请求json。代码中的所有内容均正常运行,但当我向应用程序发送数据以获取预测结果时,最后一条语句给我一个错误

url= "http://localhost:9000/api"
data = json.dumps({"sl":5.84,"sw":3.0,"pl":3.75, "pw":1.1})
r=requests.post(url,data)
r.json()

从错误日志中

json(self, **kwargs)
    884                     # used.
    885                     pass
--> 886         return complexjson.loads(self.text, **kwargs)
    887 
    888     @property

loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, use_decimal, **kw)
    516             parse_constant is None and object_pairs_hook is None
    517             and not use_decimal and not kw):
--> 518         return _default_decoder.decode(s)
    519     if cls is None:
    520         cls = JSONDecoder

0 个答案:

没有答案