Raymond Hettingershowed一种结合集合类的非常酷的方法:
from collections import Counter, OrderedDict
class OrderedCounter(Counter, OrderedDict):
pass
# if pickle support is desired, see original post
我想为OrderedDict和defaultdict做类似的事情。当然,defaultdict有一个不同的__init__
签名,因此需要额外的工作。解决这个问题最干净的方法是什么?我使用Python3.3。
我在这里找到了一个很好的解决方案:https://stackoverflow.com/a/4127426/336527,但我在想,从defaultdict派生可能会使这个过程更简单?
目前没有回答
相关问题 更多 >
编程相关推荐