{
"export": {
"version": "3.4",
"date": "2018-08-09T13:19:46Z",
"groups": [
{
"name": "Templates"
}
],
"templates": [
{
"template": "Template OS",
"name": "Template OS",
"description": "",
"groups": [
{
"name": "Datawhatiwant"
}
],
这是 JSON 代码的相关部分,我想要值datawhatiwant。但是,如果我使用print json_data["export"]
,则会出现此错误:TypeError: string indices must be integers
那么我怎样才能获得datawhatiwan呢?
你需要先解码json
import json
print(json.loads(json_data)["export"])
应该工作得更好,我想。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句