问题描述
我正在考虑将我的 Python2.x 代码库迁移到 python3.x.我的预期是做以下事情:
I'm thinking to migrate my Python2.x codebase to python3.x. My anticipation is to do the following things:
- 在 Python3 中迁移 Python2 语法
- 迁移所有使用的与 Python3 兼容的包和库
- 确保所有测试(单元测试)在迁移期间和之后都通过并迭代修复.
你有什么建议?提前致谢!
What are your suggestions? Thanks in advance!
推荐答案
项目 2to3 对此非常有帮助.
The project 2to3 is very helpful with this.
它可以处理需要发生的最常见的 Python2->Python3 代码更改.您也可以在测试中运行它.从那里我会得到一个 Python3 虚拟环境,安装 pylint,并检查你的代码库.
It can take care of the most common Python2->Python3 code changes that need to take place. You can run this on your tests also. From there I'd get a Python3 virtual environment, install pylint, and lint your codebase.
对于大型代码库,从 2 到 3 的迁移过程可能有点麻烦.这篇文章做了深入的解释.
The migration process from 2 to 3 can be a bit cumbersome for large codebases. This article does a great job with in-depth explanations.
这篇关于如何将您的代码库从 Python2 迁移到 Python3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!