您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

无法在Python 3.5.2中导入itertools

无法在Python 3.5.2中导入itertools

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
python 2022/1/1 18:29:14 有207人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶