[英]I am having a problems with collections and tuples in Python v 3.3.2
I am using the namedtuple with the collections. 我正在将namedtuple与集合一起使用。 i am getting this error 我收到此错误
NameError: name collections is not defined.
I am using Python v 3.3.2. 我正在使用Python v 3.3.2。 Any help would be very appreciated 任何帮助将不胜感激
[for Example] I am getting error on this line [例如]我在这条线上出现错误
Sale = collection.namedtuple("Sale","productid custerid date price")
Did you import collections
module? 您导入了collections
模块吗? The module name is collections
, not collection
. 模块名称是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.