更新时间:2022-05-04 09:33:02
izip_longest
被重命名 为 zip_longest
在 Python 3 中(注意,开头没有 i
),改为导入:
izip_longest
was renamed to zip_longest
in Python 3 (note, no i
at the start), import that instead:
from itertools import zip_longest
并在您的代码中使用该名称.
and use that name in your code.
如果您需要编写同时适用于 Python 2 和 3 的代码,请捕获 ImportError
以尝试其他名称,然后重命名:
If you need to write code that works both on Python 2 and 3, catch the ImportError
to try the other name, then rename:
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