将列表添加到Python字典中

时间:2017-04-24 00:13:14

标签: python json dictionary

我有一个像这样的json文件(简化):

  {'pageSize': 1,
   'vXPolicies': 
[
   {'columnType': 'Inclusion',
   'id': 123,

   'permMapList': [

    {'groupList': ['kor1'], 'permList': ['Select1'], 'userList': []},

    {'groupList': ['kor2'], 'permList': ['Select2'], 'userList': []}],

   'policyName': 'DB_policy',
    'version': '2'}]}

我想在“permMapList”下添加另一个列表:

{'groupList': ['kor3'], 'permList': ['Select3'], 'userList': []}

1 个答案:

答案 0 :(得分:1)

您可以使用append

your_dict['vXPolicies']['permMapList'].append(
    {'groupList': ['kor3'], 'permList': ['Select3'], 'userList': []})
相关问题