发请求:http://127.0.0.1:8073/api/graph/chufang?input=['发热', '头痛']
if request.method == 'GET':
r_query = request.args.to_dict()
input_text = json.loads(r_query['input'])
报错:
input_text = json.loads(r_query['input'])
File "D:\PortablePython\App\lib\json\__init__.py", line 338, in loads
return _default_decoder.decode(s)
File "D:\PortablePython\App\lib\json\decoder.py", line 365, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "D:\PortablePython\App\lib\json\decoder.py", line 383, in raw_decode
raise ValueError("No JSON object could be decoded")
原因,不能使用' '
改为 http://127.0.0.1:8073/api/graph/chufang?input=["发热", "头痛"]后,错误解决
该请求,相当于 'input='+json.dumps(["发热", "头痛"])
所以需要对r_query['input']中的内容进行json.loads