Convert python 2 code to 3 in PyCharm

前端 未结 5 1776
-上瘾入骨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

    There's a script included with Python, usually at [Python Root]/Tools/Scripts/2to3.py. You can run that script on a python file (or directory of python files) and it will handle a lot of the conversions, at least for changes in the standard library.

    It gets a little more complicated if your project uses other 3rd party libraries. It's possible the API's for those changed during the 2-to-3 transition, and the 2to3.py script will not know about those api changes. Your best bet is to run the conversion script, and then manually make any other changes that are needed.

提交回复
热议问题