Convert python 2 code to 3 in PyCharm

前端 未结 5 1820
-上瘾入骨i
-上瘾入骨i 2020-12-08 04:48

I have a large ML project in python 2 code and I just started using PyCharm as an IDE. I\'m currently using WinPython 3.4 and I\'d preferably like to do everything in python

5条回答
  •  情话喂你
    2020-12-08 05:35

    I found a way in Pycharm IDE to convert file from v2 to v3 using 2to3 tool.

    I applied in pycharm comunity edition v 2016.2.3 in windows environment.

    • click terminal in status bar Now, you are in shell command, in the root of your project.
    • type the command (to convert myfile.py):
    2to3 myfile.py -w
    

    The tool modifies the code of the file, and your IDE is reflected with the changes.

    To modify all your files in the folder, type the command

    2to3 . -w
    

    The option -w to actually write the changes. For more details write:

    2to3 -h
    

提交回复
热议问题