【发布时间】:2011-06-19 04:27:53
【问题描述】:
我一直在尝试在 Python 3.2 中使用 Counter 方法,但我不确定我是否正确使用它。知道为什么我会收到错误消息吗?
>>> import collections
>>> Counter()
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
Counter()
NameError: name 'Counter' is not defined
如果我访问 collections.Counter(),我可以访问 Counter,但不能访问文档中的示例。
【问题讨论】:
标签: python python-3.x