如何将 Python 2 代码移植到 Python 3¶
- 作者:
Brett Cannon
Python 2 reached its official end-of-life at the start of 2020. This means that no new bug reports, fixes, or changes will be made to Python 2 - it's no longer supported: see PEP 373 and status of Python versions.
如果您希望迁移扩展模块而不是纯 Python 代码,请参阅 将扩展模块移植到 Python 3。
已归档的 python-porting 邮件列表可能包含一些有用的指导。
Since Python 3.13 the original porting guide was discontinued. You can find the old guide in the archive.
Third-party guides¶
There are also multiple third-party guides that might be useful: