How can I convert defaultdict(Set) to defaultdict(list)?
问题 I have a defaultdict(Set) : from sets import Set from collections import defaultdict values = defaultdict(Set) I want the Set functionality when building it up in order to remove duplicates. Next step I want to store this as json. Since json doesn't support this datastructure I would like to convert the datastructure into a defaultdict(list) but when I try: defaultdict(list)(values) I get: TypeError: 'collections.defaultdict' object is not callable , how should I do the conversion? 回答1: You