Skip to main content
 首页 » 编程设计

python之如何在 python 中创建唯一的嵌套字典列表

2025年05月04日16findumars

<分区>

我有下面的嵌套字典列表:

[{'permission': 'full', 
  'permission_type': 'allow', 
  'trustee': {'id': 'SID:S-1-5-32-545', 
              'name': 'Users', 
              'type': 'group'}}, 
 {'permission': 'full', 
  'permission_type': 'allow', 
  'trustee': {'id': 'SID:S-1-5-32-545', 
              'name': 'Users', 
              'type': 'group'}}, 
 {'permission': 'full', 
  'permission_type': 'allow', 
  'trustee': {'id': 'SID:S-1-5-32-544', 
              'name': 'Administrators', 
              'type': 'group'}}] 

我想让它独一无二,尝试了不同的建议但没有成功。 有人可以帮助使它在 python 2.6 中独一无二吗?上面的数据中没有键/唯一字段。 我希望得到以下结果(列表中的一个成员作为完整副本被删除):

[{'permission': 'full', 
  'permission_type': 'allow', 
  'trustee': {'id': 'SID:S-1-5-32-545', 
              'name': 'Users', 
              'type': 'group'}}, 
 {'permission': 'full', 
  'permission_type': 'allow', 
  'trustee': {'id': 'SID:S-1-5-32-544', 
              'name': 'Administrators', 
              'type': 'group'}}]