【发布时间】:2026-01-10 03:10:01
【问题描述】:
我有一个字典列表:
l = [{u'content': [], u'name': u'child_01'}, {u'content': [], u'name': u'child_01'} ,{u'content': [], u'name': u'child_04'}]
我想检测重复并用
替换它们{u'content': [], u'name': u'child'}
set 不适用于字典。
【问题讨论】:
-
示例中列表的输出应该是什么?
-
仅基于
u'name'的重复项? -
键相同但值不同的条目怎么办?两者不能存储在同一个字典中。
-
1.在输出中,我需要将其中一个重复的字典替换为另一个。 2. 是的,基于 u'name'。 3.我不能换字典
标签: python python-2.7 list dictionary