2013-03-16 68 views
1

,我发现了以下错误:无法找到我的Python 3.3语法错误

File "foo.py", line 6 
    print "This implementation requires the numpy module." 
                 ^
SyntaxError: invalid syntax 

在这个Python代码:

#!/usr/bin/python 

try: 
    import numpy 
except: 
    print "This implementation requires the numpy module." 
    exit(0) 

############################################################################### 

if __name__ == "__main__": 
    R = [ 
     [1,2,3], 
     [4,5,6] 
     ] 

有什么不对?

编辑:我使用Python 3.3

+0

请告诉python版本 – GodMan 2013-03-16 12:07:19

+3

使用Python 3.x? [打印是函数](http://docs.python.org/3.0/whatsnew/3.0.html) – Ben 2013-03-16 12:07:33

+0

是的,Python 3.3 – gurehbgui 2013-03-16 12:10:25

回答

6

这应该是:

print("....") 

与Python 3开始,print是一个函数,而不是一个特殊的case语句。