在字典中有重复的值,例如:
dict_numbers={'one':['one', 'first','uno', 'une'],
'zero':['zero','nothing','cero'],
'first':['one', 'first','uno', 'une'],
'dos':['two','second','dos', 'segundo','deux'],
'three':['three','tres','third','tercero'],
'second':['two','second','dos','segundo','deux'],
'forth':['four','forth', 'cuatro','cuarto'],
'two': ['two','second','dos', 'segundo','deux'],
'segundo':['two','second','dos', 'segundo','deux']}
我想获得具有重复值的键的第一次出现。请注意,字典没有重复的键,而是重复的值。在这个例子中,我会得到一个列表来保存重复值的第一次出现:
list_numbers_no_duplicates=['one','zero','dos','three','forth']
first
键被删除,因为one
已经具有相同的值。
second
键被删除,因为dos
已经具有相同的值。
two
键被删除,因为dos
已经具有相同的值。
如何跟踪键值中的几个重复项?
提前致谢