Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mac上的Python 3.2.2打印函数语法错误,但Windows上没有_Python_Windows_Macos_Printing_Syntax Error - Fatal编程技术网

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

Mac上的Python 3.2.2打印函数语法错误,但Windows上没有,python,windows,macos,printing,syntax-error,Python,Windows,Macos,Printing,Syntax Error,我目前正在Mac上测试一个在Windows中开发的python程序,该程序基于python 3.2。当程序在Windows上运行时没有问题,但在Mac上运行时,我得到一个指向以下打印函数的语法错误: LOGFILE = open('./test.log','w') print('Testing Started\n', file = LOGFILE) ^ SyntaxError: invalid syntax 我运行的是Python

我目前正在Mac上测试一个在Windows中开发的python程序,该程序基于python 3.2。当程序在Windows上运行时没有问题,但在Mac上运行时,我得到一个指向以下打印函数的语法错误:

LOGFILE = open('./test.log','w')
print('Testing Started\n', file = LOGFILE)
                                ^
SyntaxError: invalid syntax
我运行的是Python3.2.2,所以我认为这是正确的语法-我无法理解哪里出了问题。奇怪的是,当我更改为旧的2.X语法时

print >>LOGFILE, "Test Started\n"
它运行正常

我的python解释器虽然是3.2.2版,但仍然使用旧语法,这有什么原因吗


谢谢。

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


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

python-v myfile.py
在Mac上运行时将其转储并报告找到的内容。您还可以使用
import sys;打印(sys.version)
以验证这一点。