前景提要
flask-restful 扩展 json 返回中文乱码 背景 https://v2ex.com/t/694457 #通过以下代码已解决中文乱码 api.representations = {'application/json;charset=utf-8': output_json}
新问题 #python 、rust 等测试正常 import requests res = requests.get(url="http://127.0.0.1:5000/api/v1/login") print(res.text) #go 测试异常 resp,_ := http.Get("http://127.0.0.1:5000/api/v1/login") body,_ :=ioutil.ReadAll(resp.Body) fmt.Println(string(body)) #错误详情 File "site-packages\flask\app.py", line 1950, in full_dispatch_request rv = self.dispatch_request() File "site-packages\flask\app.py", line 1936, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "site-packages\flask_restful\__init__.py", line 472, in wrapper return self.make_response(data, code, headers=headers) File "site-packages\flask_restful\__init__.py", line 509, in make_response raise InternalServerError() #注释之前添加代码,go 测试正常 #api.representations = {'application/json;charset=utf-8': output_json} #请问问题出在哪儿呢?