TypeError:**后面的jsonify()参数必须是映射,而不是使用Flas返回JSON的列表

2024-06-06 17:34:17 发布

您现在位置:Python中文网/ 问答频道 /正文

我在用烧瓶和壁炉。我的功能是:

@app.route('/index',methods=['POST'])
def index():
....
....
gevent.joinall(threads)
res = [t.value for t in threads]
return jsonify(**res)

生成的响应(res)是一个字典列表,如下所示:

[{u'token': u'146bf00b2cb96e6c425c2ab997637', u'a': u'aaa'},{u'token': u'146bf00b2cb96e6c425c2ab3f7417', u'a': u'bbb'}, {u'token': u'146bf00b2cb96e6c425c2ab3f5692', u'a': u'ccc'} ]

当我试着解决这个问题时,我得到:

TypeError: jsonify() argument after ** must be a mapping, not list

我做错什么了?


Tags: 功能tokenappindex烧瓶defgeventres