Python 通过字符串标识从url获取json

Python 通过字符串标识从url获取json,python,flask,Python,Flask,Url:127.0.0.1:5000/mywebservice?&list=hello&list=world&dict={“type”:“mail”,“subject”:“hello”,“content”:“hello world”} 我正在尝试从url获取json list=request.args.getlist(list)允许我这样获取列表list[0]=hello,list[1]=world URL如下所示: Url:127.0.0.1:5000/mywebservice&list=h

Url:127.0.0.1:5000/mywebservice?&list=hello&list=world&dict={“type”:“mail”,“subject”:“hello”,“content”:“hello world”}

我正在尝试从url获取json list=request.args.getlist(list)允许我这样获取列表list[0]=hello,list[1]=world

URL如下所示:


Url:127.0.0.1:5000/mywebservice&list=hello&list=world&dict[type]=mail&dict[subject]=hello&dic[content]=hello world


有没有一种方法可以让我这样得到字典

预期结果:

dic=request.args.get(dict)

var= dic['type']

print(var)====> mail
然而:

dic = request.args.get(dict)
var = dic['type']
print(var) : Exception
PS:request.json没有访问url的权限,也没有访问权限

 dic = request.args.getjson(dict)

如果我正确理解URL中的
dict
,我将序列化JSON。您需要使用
json
包对其进行反序列化

导入json
url\u dict=request.args.get('dict')
dic=json.loads(url\u dict)
打印(dic[“类型”])

我现在就是这样工作的,我正在寻找一种方法来处理url的第二个示例:127.0.0.1:5000/mywebservice&list=hello&list=world&dict[type]=mail&dict[subject]=hello&dic[content]=hello world如果你想这样做,你将失去用一个变量获取查询参数信息的能力。通常人们不喜欢这样做。