简体   繁体   中英

How to Remove Both Duplicates from a Dictionary?

I'm writing a reducer for a MapReduce program that is supposed to read two csv files: all-bills.csv and open-bills.csv . What I want to do is remove values in open-bills from all bills so that I can get all the paid bills.

What I have done is to add all the entries into a dictionary in my reducer. How do I remove the entries that occur twice or more than that so that I'm left with just the paid bills in my dictionary?

尝试这个:

{k: v for k, v in all_bills.items() if k not in open_bills}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM