我有两个字典,一旦它们都被构建,键(和值)中有一些重叠我想从其中一个中删除键,另一个中存在的值。基于这个问题和亚历克斯马泰利的回答我试过
from collections import defaultdict
some_dictionary # a defaultdict(list)
other_dictionary # a defaultdict(list) has some duplicate k,v pairs
other_dictionary = defaultdict((key,other_dictionary[key]) for key in other_dictionary if key not in some_dictionary)
当我这样做时,我得到一个错误
TypeError: first argument must be callable