requests.post('http://127.0.0.1:5000/image/test', data=json.dumps(data))
發送請求時,flask接口這邊得到的值為None,原因是因為請求頭中缺少content-type參數,請求頭中加入即可。
headers = { "Content-Type": "application/json;charset=utf8" } requests.post('http://127.0.0.1:5000/image/test', data=json.dumps(data), headers=headers)
這樣的話就行了。
或者可以用request.get_data(as_text=True),然后用json.loads()去加載也行