Python Flask,通过字典列表,获取字符串
我正在学习flask,并试图将字典列表传递给重定向。命令Python Flask,通过字典列表,获取字符串,python,python-2.7,flask,Python,Python 2.7,Flask,我正在学习flask,并试图将字典列表传递给重定向。命令request.args.getlist(字典列表返回字符串列表。我很难理解如何将它们作为字典 下面是我的代码: a = {'length': '40', 'type': 'phone', 'name': 'Fax', 'label': 'Fax'} b = {'length': '255', 'type': 'string', 'name': 'Name', 'label': 'Name'} list_of_dictionaries =
request.args.getlist(字典列表
返回字符串列表。我很难理解如何将它们作为字典
下面是我的代码:
a = {'length': '40', 'type': 'phone', 'name': 'Fax', 'label': 'Fax'}
b = {'length': '255', 'type': 'string', 'name': 'Name', 'label': 'Name'}
list_of_dictionaries = [a,b]
listOfObjects = ['Account','Opportunity','Lead']
@app.route('/found', methods=['GET','POST'])
def found():
keys = request.args.getlist('keys')
obj = request.args.getlist('obj')
return render_template("found.html",keys=keys,obj=obj)
@app.route('/finder', methods=['GET','POST'])
def finder():
if request.method == 'POST'
return redirect(url_for('clientfound',keys=list_of_dictionaries,obj=listOfObjects))
else:
return render_template('base.html')
也许您可以简单地使用request.args.get()然后使用json.load