如何使用2to3.py工具将python2.x代码迁移至python3版本?
- 内容介绍
- 文章标签
- 相关推荐
本文共计287个文字,预计阅读时间需要2分钟。
1. 在Windows中使用命令提示符(cmd)导航到2to3.py脚本所在位置,例如: cd /path/to/2to3.py 如下所示: +----------------+ | 找不到2to3.py | +----------------+ 接着,在PyCharm中双击shift搜索2,然后选择2to3.py脚本进行编辑。
2. 直接运行2to3.py脚本(如果可用): python 2to3.py
3. 执行你想要转换的文件: python 2to3.py -w /path/to/your/file.py
1.使用Windows 命令提示符(cmd)cd到2to3.py 脚本所在位置,如下图:
找不到的2 to 3.py的去 pycharm中双击shift搜索一下
2.紧接着运行2to3.py 脚本(可省略)
3.执行你想要转换的文件
python 2to3.py -w H:\QIANfeng\sacrapy\图片识别.py
如果出现了上图这个报错
RefactoringTool: Can't parse H:\QIANfeng\sacrapy\图片识别.py: ParseError: bad input: type=24, value='%', context=('', (18, 6))
RefactoringTool: No files need to be modified.
RefactoringTool: There was 1 error:
RefactoringTool: Can't parse H:\QIANfeng\sacrapy\图片识别.py: ParseError: bad input: type=24, value='%', context=('', (18, 6))
说明是一个不正确的puthon2 文件你去修改一下就可以了
在运行第三步。
本文共计287个文字,预计阅读时间需要2分钟。
1. 在Windows中使用命令提示符(cmd)导航到2to3.py脚本所在位置,例如: cd /path/to/2to3.py 如下所示: +----------------+ | 找不到2to3.py | +----------------+ 接着,在PyCharm中双击shift搜索2,然后选择2to3.py脚本进行编辑。
2. 直接运行2to3.py脚本(如果可用): python 2to3.py
3. 执行你想要转换的文件: python 2to3.py -w /path/to/your/file.py
1.使用Windows 命令提示符(cmd)cd到2to3.py 脚本所在位置,如下图:
找不到的2 to 3.py的去 pycharm中双击shift搜索一下
2.紧接着运行2to3.py 脚本(可省略)
3.执行你想要转换的文件
python 2to3.py -w H:\QIANfeng\sacrapy\图片识别.py
如果出现了上图这个报错
RefactoringTool: Can't parse H:\QIANfeng\sacrapy\图片识别.py: ParseError: bad input: type=24, value='%', context=('', (18, 6))
RefactoringTool: No files need to be modified.
RefactoringTool: There was 1 error:
RefactoringTool: Can't parse H:\QIANfeng\sacrapy\图片识别.py: ParseError: bad input: type=24, value='%', context=('', (18, 6))
说明是一个不正确的puthon2 文件你去修改一下就可以了
在运行第三步。

