如何从python中的字典中获取projectID值?

时间:2014-03-12 06:42:27

标签: python python-2.7

需要提取projectID,我的最终输出是1868117666669。

'{
    "code":"ok",
    "job":{
        "config":{
            "progress":{
                "message":"Reading 2014-03-03__12-57-01-PM.xml",
                "percent":107,
                "maxmemory":954,
                "memory":667
            },
            "projectID":1868117666669,
            # other stuff
            }
        }
  }'

1 个答案:

答案 0 :(得分:0)

你可以尝试

>>> a = '{"code":"ok","job":{"config":{"progress":{"message":"Reading 2014-03-03__12-57-01-PM.xml","percent":107,               "maxmemory":954,"memory":667},"projectID":1868117666669}}}'

>>> json.loads(a)['job']['config']['projectID']
1868117666669