首页 > 解决方案 > 你能帮忙编辑json吗,我是python的新手。谢谢

问题描述

我需要编辑一些 json 配置,为了节省我的时间,我想使用 python 自动编辑它,但是数据对我来说很复杂,你能帮帮我吗?

tes={
'key':1, 'Test':45, 'name':'Google',
'list':[{
    'nameinlist':'name1',
    'age':23,
    'country':'LA',
    'parent':{'name':'World'},
    'zipcodeindic':[23,45,66]
    }]
}

我想修改

'nameinlist':'name1'->'nameinlist':'name2'
'parent':{'name':'World'} ->'parent':{'name':'World2'}
'zipcodeindic':[23,45,66]->'zipcodeindic':[23,33,66]

标签: pythonjson

解决方案


tes['list'][0]['nameinlist']='name2'
tes['list'][0]['parent']={'name':'World2'}
tes['list'][0]['zipcodeindic']=[23,33,66]

推荐阅读