【发布时间】:2015-11-22 13:31:08
【问题描述】:
>>> itertools.izip('ABCD', 'xy')
Traceback (most recent call last):
File "<pyshell#55>", line 1, in <module>
itertools.izip('ABCD', 'xy')
AttributeError: 'module' object has no attribute 'izip'
【问题讨论】:
-
您使用的是哪个版本的 Python?在 Python 3 中,内置函数
zip的行为类似于 Python 2 中的itertools.izip。 -
Blckknght 是对的。如果你不知道如何找到 python 版本,请看这里:stackoverflow.com/questions/9079036/…
-
@Blckknght 嗨,Blckknght,我使用的是 3.4.3 版。您也可以在 shell 窗口的顶部栏中看到它。我对 string.maketrans(...) 有同样的问题。见:
-
>>> trans = string.makestrans('ae','bx') Traceback(最近一次调用最后):文件“
”,第 1 行,在 中= string.makestrans('ae','bx') AttributeError: 'module' object has no attribute 'makestrans'