我从Python 2.7迁移到Python 3.3并且zip()不再按预期工作.实际上,我在文档中读到它现在返回迭代器而不是列表.
那么,我该如何应对呢?我可以在Python3代码中使用"旧"zip()吗?
在Django项目中找到它以前的工作方式:
在views.py中: my_zipped_list = zip(list1, list2)
my_zipped_list = zip(list1, list2)
在file.html中: {{ my_zipped_list.0.1 }}
{{ my_zipped_list.0.1 }}
也许另一种解决方案是保持"新"zip()行为并改为改变模板.
感谢帮助!
python django python-3.x
django ×1
python ×1
python-3.x ×1