繁体   English   中英

我在Python v 3.3.2中遇到集合和元组的问题

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM