Warm tip: This article is reproduced from serverfault.com, please click

其他-如何正确使用2to3用于python?

(其他 - How to use 2to3 properly for python?)

发布于 2013-12-08 19:35:20

我在python 2.7中有一些代码,我想将它们全部转换成python 3.3代码。我知道可以使用2to3,但是我不确定如何使用它。

Questioner
GhostFrag1
Viewed
11
3,711 2020-11-27 09:49:39

安装以下模块,该模块将2to3命令直接添加到entry_points。

pip install 2to3

正如2to3 docs所写,要将整个项目从一个目录树转换到另一个目录树,请使用:

2to3 --output-dir=python3-version/mycode -W -n python2-version/mycode