使用2to3.py 转换 python2.x 代码 到python3

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 文件你去修改一下就可以了

在运行第三步。

猜你喜欢

转载自blog.csdn.net/qq_41856814/article/details/90169837