Discuss / Python / Counter怎么实现

Counter怎么实现

Topic source

onion_4

#1 Created at ... [Delete] [Delete and Lock User]

class Counter(dict): pass c = Counter() for ch in 'programming': try: c[ch] except: c[ch]=0 c[ch] = c[ch] + 1

本来想在Counter里面加getitem去操作,最后无限递归了,先这样。


  • 1

Reply