参考内容:https://docs.python.org/zh-cn/3.7/library/2to3.html
然后新建文件:python 2to3.reg
文件内容:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Python.File\Shell\editwithidle\shell\2to3\command]
@="cmd /c C:\\Users\\Joe\\AppData\\Local\\Programs\\Python\\Python37\\Tools\\scripts\\2to3.py -w \"%1\""
其中C:\\Users\\Joe\\AppData\\Local\\Programs\\Python\\Python37\\Tools\\scripts\\2to3.py 为自己的文件路径路径。
找到自己python下的2to3.py 然后注意转义。
保存好了直接双击
会有提示:
点击确定
找到要转换的程序,右键
选择Edit with IDLE 然后选择 2to3
然后就转换成python3完成。
会在文件目录同时生成该文件的.bak文件,这是该文件python2的备份文件。