如何为python正确使用2to3? [英] How to use 2to3 properly for python?

查看:37
本文介绍了如何为python正确使用2to3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have some code in python 2.7 and I want to convert it all into python 3.3 code. I know 2to3 can be used but I am not sure exactly how to use it.

推荐答案

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

Install the following module which adds the 2to3 command directly to entry_points.

pip install 2to3

正如它写在 2to3 docs 上那样,翻译整个项目一个目录树到另一个,使用:

As it is written on 2to3 docs, to translate an entire project from one directory tree to another, use:

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

这篇关于如何为python正确使用2to3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆