我尝试使用flaskrestfulapi,作为返回值,代码应该返回json数据列表。但是,当json中的内容是非ascii字符(òsèò)时,返回值
以下是示例代码:
#! /usr/bin/env python
# coding: utf-8
from flask import Flask, Response
from flask_restful import Resource, Api
import json
app = Flask(__name__)
# Create the API
API = Api(app)
@app.route('/')
def hello_world():
return Response('Here, with Response it works well: höne')
class APICLASS(Resource):
"""
"""
def get(self, id):
return [
{
"hey": 11,
"test": "höne"
}], 200
API.add_resource(APICLASS, '/<string:id>')
if __name__ == '__main__':
app.run(debug=True)
但是当我在localhost上检查结果时,我看到以下输出:
^{pr2}$
显然,它与this bug有关。 我不确定是否有任何副作用,但这可能有帮助:
相关问题 更多 >
编程相关推荐