2012-06-17 35 views
18

我试图通过运行命令如何在Windows中使用2to3工具?

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

修改使用2to3的工具sintax,并得到了输出

enter image description here

当打开neo4j.py但是我注意到没有发生过任何改变。下面是其中的变化(accoridng输出)应作出的代码块:

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

有谁知道如何才能正确使用2to3的工具来港/更改代码到V3.2?

+0

新版本( http://pypi.python.org/pypi/py2neo)py2neo宣称Python 3兼容性开箱即用。 – ChristopheD

+0

我试过这个版本,但它不起作用 –

回答

39

您必须使用-w标志实际上写的变化:

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

2to3.py documentation

+0

我刚刚得到字母C的invalis sytax: –

+0

@ Ifyoudonotknow-justGIS你是什么意思? – sbrm1

0

作为除了公认的答案,

复制此行C:\python32\Scripts\2to3.bat

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

之后,你就可以使用

2to3 -w neo4j.py