Python 3.2.2在Mac上打印函数语法错误但在Windows上没有

use*_*086 3 python windows printing macos syntax-error

我目前正在Mac上测试一个在Python 3.2上用Windows开发的python程序.当程序在Windows上运行时没有问题,但是当在Mac上运行时,我收到指向以下打印功能的语法错误:

LOGFILE = open('./test.log','w')
print('Testing Started\n', file = LOGFILE)
                                ^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)

我正在运行Python 3.2.2,所以我认为这是正确的语法 - 我无法理解什么是错的.奇怪的是,当我改变旧的2.X语法时,

print >>LOGFILE, "Test Started\n"
Run Code Online (Sandbox Code Playgroud)

它运行没有错误.

可能有一些原因我的python解释器使用旧的语法,即使它是版本3.2.2?

谢谢.

NPE*_*NPE 6

最可能的解释是您使用Python 2.x运行脚本.系统上可能安装了多个解释器,因此我建议您确保使用您认为正在使用的解释器.

尝试sys.version从脚本中打印出来.