How to use 2to3 properly for python?

后端 未结 9 936
野趣味
野趣味 2020-12-04 17:26

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.

9条回答
  •  情话喂你
    2020-12-04 18:20

    To convert the code from python2 to python3 first install the 2to3 package by using

    pip install 2to3
    

    Then run this command in directory where is your python code

    2to3 -w -n .
    
    • -w flag to enable writeback, which applies the changes to the file
    • -n to disable backups

提交回复
热议问题