2013-03-16 67 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語句。