izip_longest
在Python 3中被 重命名 为zip_longest
(请注意,i
开头没有),而是导入:
from itertools import zip_longest
如果您需要编写适用于Python 2和3的代码,请抓住ImportError
尝试使用其他名称,然后重命名:
try:
# Python 3
from itertools import zip_longest
except ImportError:
# Python 2
from itertools import izip_longest as zip_longest
# use the name zip_longest