Remove duplicates from list of dicts

后端 未结 2 1187
失恋的感觉
失恋的感觉 2020-12-20 08:00

I presently have the ability to remove duplicates if there is no key in front of the nested dictionary. An example of my list of dicts that works with this function is:

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-20 08:20

    To remove duplicates from a list of dicts:

    list_of_unique_dicts = []
    for dict_ in list_of_dicts:
        if dict_ not in list_of_unique_dicts:
            list_of_unique_dicts.append(dict_)
    

提交回复
热议问题