Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Flask,通过字典列表,获取字符串_Python_Python 2.7_Flask - Fatal编程技术网

Python 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 =

我正在学习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 = [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