How to use 2to3 properly for python?
问题 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. Thanks for any help 回答1: 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 回答2: If you don't have 2to3 on your path, you can directly invoke lib2to3 : python -m lib2to3 directory\file.py And as the docs (and other answers)