[英]I am having a problems with collections and tuples in Python v 3.3.2
我正在将namedtuple与集合一起使用。 我收到此错误
NameError: name collections is not defined.
我正在使用Python v 3.3.2。 任何帮助将不胜感激
[例如]我在这条线上出现错误
Sale = collection.namedtuple("Sale","productid custerid date price")
您导入了collections
模块吗? 模块名称是collections
,而不是collection
。
>>> Sale = collection.namedtuple("Sale","productid custerid date price")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'collection' is not defined
>>>
>>> import collection
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named collection
>>>
>>> import collections
>>> Sale = collections.namedtuple("Sale","productid custerid date price")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.