這裏沒有可行的替代方案是我的代碼:打印數1-10蟒蛇 - 錯誤:在輸入 '='
for i in range(10):
print(i, end=' ') #This line is throwing an error
SyntaxError: no viable alternative at input '='
我使用NetBeans和Jython 2.7.0
這裏沒有可行的替代方案是我的代碼:打印數1-10蟒蛇 - 錯誤:在輸入 '='
for i in range(10):
print(i, end=' ') #This line is throwing an error
SyntaxError: no viable alternative at input '='
我使用NetBeans和Jython 2.7.0
你用python-2.7和python-3.x標記它,但是這不應該在Python3中引發問題。
問題出在Python2中,print
是一個語句,所以end = ' '
是無效的語法。
爲了得到相同的結果,請將from __future__ import print_function
放在腳本的開頭,或者改爲print i,
。
得到'SyntaxError:即使在導入Jython 2.7.0之後,輸入'='錯誤也沒有可行的替代方法。儘管在cPython中工作。 – Wally
我認爲@zondo是正確的。檢查這個http://stackoverflow.com/questions/2456148/python-print-end – arifin4web