當我把這個Python代碼到REPL的Python(交互式shell)的罰款,它按預期工作:Python語法錯誤,在REPL
>>> def get_header():
... return (None,None,None)
...
>>> get_header()
(None, None, None)
注意,return語句由四個縮進空格,我已經檢查過以確保沒有多餘的空格。
當我把確切相同的代碼爲Python腳本文件並執行它,我收到以下錯誤:
./test.py: line 1: syntax error near unexpected token `('
./test.py: line 1: `def get_header():'
爲什麼?
編輯:這是test.py的確切內容,空格和所有:
def get_header():
return (None,None,None)
get_header()
我已驗證了上面的腳本(test.py)不會產生上述錯誤,因爲它以上站着。
請發佈test.py,indentation和所有內容。 –
也許在第1-4行? –
我叫shenanigans。至少發佈test.py文件的第1行到第6行。 – tylerl