如何在Windows中使用2to3工具?

Nik*_*lin 24 python python-2to3

我尝试通过运行命令使用2to3工具修改sintax

python C:\Python32\Tools\scripts\2to3.py neo4j.py
Run Code Online (Sandbox Code Playgroud)

得到了输出

在此输入图像描述

打开neo4j.py时,我注意到没有任何改变.下面是应该进行更改(符合输出)的代码块:

try:
    import json
except ImportError:
    import simplejson as json
try:
    from urllib.parse import quote
except ImportError:
    from urllib import quote
try:
    from . import rest, batch, cypher
except ImportError:
    import rest, batch, cypher
except ValueError:
    import rest, batch, cypher

import logging
logger = logging.getLogger(__name__)
Run Code Online (Sandbox Code Playgroud)

有没有人知道如何正确使用2to3工具,以便将代码移植/更改为v3.2?

Sim*_*ser 48

您必须使用该-w标志来实际编写更改:

python C:\Python32\Tools\scripts\2to3.py -w neo4j.py
Run Code Online (Sandbox Code Playgroud)

请参阅2to3.py文档.