I generated a python dictionary for all the duplicate images in a folder. The python dictonary now contains values in the following format:
{
"image_1.jpg": ['image_xyz.jpg', 'image_abc.jpg'],
"image_xyz.jpg": ["image_1.jpg", "image_abc.jpg"],
"image_abc.jpg": ["image_xyz.jpg","image_1.jpg"],
"image_2.jpg": ["image_3.jpg"],
"image_3.jpg": ["image_2.jpg"],
"image_5.jpg": []
}
Each key, value pair thus appears atleast twice in the list. Empty list for keys are present which have no duplicates.
Is there a way to delete all the duplicate key value pairs present? so that the dictionary looks like the following:
{
"image_1.jpg": ['image_xyz.jpg', 'image_abc.jpg'],
"image_2.jpg": ["image_3.jpg"],
"image_5.jpg": []
}
I tried using list to first store all the values from the key value pair and then deleting them from the dictionary but it empties the whole dictionary.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…