วันพฤหัสบดีที่ 13 มิถุนายน พ.ศ. 2556

How to convert python2 to python3

Hi every body.
It just simply to convert python2 to python3. You can convert by using the command name "2to3" that give in python3.x. to convert

If you want to convert example.py (Implenment on python2.x) type bellow.

$ python3
>>> 2to3 -w example.py

-w option is to replace the converted code to original code.

So if you want to convert all .py in folder. You can to shell script to do it. That is bellow

  #!/bin/sh
  for i in $( find . -name "*.py");
  do
  echo "start 2to3 $i";
  2to3 -w $i
  done;


Thank for P'boat for coding ^^

ไม่มีความคิดเห็น:

แสดงความคิดเห็น