# python 2.7.6
# 2to3Test.py
print "Hello,World!"
用
python27
显然是可以编译的
:
D:\Python>python27 2to3Test.py
Hello,World!
用
python33
就编译不过了,因为
3
里
是函数,这样写就会有语
法错误。
D:\Python>python33 2to3Test.py
File "2to3Test.py", line 1
print "Hello,World!"
^
SyntaxError: invalid syntax
下面用
python3
中自带的
2to3
工具进行转换
:
D:\Python>python C:\Python33\Tools\Scripts\2to3.py -w 2to3Test.py
RefactoringTool: Skipping implicit fixer: buffer
RefactoringTool: Skipping implicit fixer: idioms
RefactoringTool: Skipping implicit fixer: set_literal