Convert python 2.7 into Python 3.4
Hello and welcome in this tutorial im going to teach you cool trick.how to convert the python 2 script in to python 3 script it is easy.here is the step im going to do
create new folder in desktop
then save my python 2.7 file in that folder
then select the folder that i created before and press shift and then press right click it will ask for open command prompt here select it and boom then it will open the command prompt
after that you have to type like this
python C:/Python/Tools/scripts/2to3.py then your file name
ex:-
python C:/Python/Tools/scripts/2to3.py mypythonfile.py
then press enter then it will show you the points you need to change [-] mark will represent the changes you wanna do.
or you can make the changes automatically you can type -w before your file name then it will automatically fix the errors for you
python C:/Python/Tools/scripts/2to3.py -w myfile.py
here is my python 2.7 file
i saved in new folder in desktop
Press Shift and press right click to open command prompt in that folder
check corrections
errors are marked
Errors are fixed using -w command
Errors are fixed now
lets see the new changed code
Lets run the code and see the result
No comments:
Post a Comment