【发布时间】:2014-12-15 01:13:20
【问题描述】:
我正在查看包含此更改的 2to3 的输出:
- for file_prefix in output.keys():
+ for file_prefix in list(output.keys()):
output 是字典。
这种变化有什么意义?为什么2to3会这样做?
此更改如何使代码与 Python 3 兼容?
【问题讨论】:
-
在 python 2 上尝试
d.keys()[0],然后在 python 3 上尝试 -
什么时候最好的改变是
for file_prefix in output:,但是py2to3猜不到。
标签: python python-3.x python-2to3