Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.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
如何在JSON项中将值指定为具有新值的键?_Json_Python 3.x_Dictionary - Fatal编程技术网

如何在JSON项中将值指定为具有新值的键?

如何在JSON项中将值指定为具有新值的键?,json,python-3.x,dictionary,Json,Python 3.x,Dictionary,我有两条数据,第一条是json结果(缩短,剪裁在这里)- hold['results']['concepts'] [ { 'dbpedia_resource':'http://dbpedia.org/resource/Posttraumatic_stress_disorder', 'relevance': 0.946535, 'text': 'Posttraumatic stress disorder' }, {

我有两条数据,第一条是json结果(缩短,剪裁在这里)-

hold['results']['concepts']

[
    {
        'dbpedia_resource':'http://dbpedia.org/resource/Posttraumatic_stress_disorder',
        'relevance': 0.946535,
        'text': 'Posttraumatic stress disorder'
    },
    {
        'dbpedia_resource': 'http://dbpedia.org/resource/Hypnotherapy',
        'relevance': 0.870893,
        'text': 'Hypnotherapy'
    }
]
第二个是175的值

我想让他们彼此团结起来,这样看起来:

[
    {
        'Posttraumatic stress disorder': 175
    },
    {
        'Hypnotherapy': 175
    }
]

谢谢大家!

我自己想出来的

dicts={}

for i in hold['results']['concepts']:
    dummy=i['text']
    dict1 = {dummy:175}
    dicts.update(dict1)