我的资料来源是:
"VirtualizationType": "hvm",
"Tags": [
{
"Value": "Test",
"Key": "Name"
}
]
这是我的一些代码:
for item in result:
temp = {"Tags": item["Value"], "VirtualizationType": item["VirtualizationType"]}
output.append(temp)
我可以轻松导出VirtualizationType,但不能使用标签做到这一点
如何从docs用Python创建字典的示例:
tel = {'jack': 4098, 'sape': 4139}
在这个例子中jack
,snape
是键,4098
,4139
是的值。
值也可以是字符串和字典列表,例如您的情况,您的代码可以修改为:
dictionary = {"Virtualization Type" : "hvm", "Tags" : [{"Value" : "Test", "Key" : "Name"}] } #Runs in the python interpreter with no errors
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句