简体   繁体   English

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

[英]How to use 2to3 tool in windows?

I tried to modify the sintax using 2to3 tool by running command 我试图通过运行命令使用2to3工具修改sintax

python C:\Python32\Tools\scripts\2to3.py neo4j.py

and got the output 得到了输出

在此处输入图片说明

When opening neo4j.py however I noticed there hasn't been anything changed. 但是当打开neo4j.py时,我没有发现任何变化。 Below is the block of code where changes (accoridng to output) should be made: 以下是应进行更改(根据输出)的代码块:

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__)

Does anyone know how to use 2to3 tool properly in order to port/change the code to v3.2? 有谁知道如何正确使用2to3工具以便将代码移植/更改为v3.2?

You have to use the -w flag to actually write the changes: 您必须使用-w标志来实际写入更改:

python C:\Python32\Tools\scripts\2to3.py -w neo4j.py

See the 2to3.py documentation . 请参阅2to3.py文档

As an addition to the accepted answer, 除了接受的答案之外,

Copy this line to C:\\python32\\Scripts\\2to3.bat : 将此行复制到C:\\python32\\Scripts\\2to3.bat

@python %~dp0..\tools\scripts\2to3.py %*

After that you'll be able to use 之后,您将可以使用

2to3 -w neo4j.py

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM