Python代码有效,但eclipse显示错误 - 检测元组时出现语法错误

Bor*_*yev 12 python eclipse python-3.x

我是python的新手.我在Eclipse Kepler中使用Python 3.3.

这是我的代码片段:

f = Fibonacci(0,1)
for r in f.series():
    if r > 100: break
    print(r, end=' ')
Run Code Online (Sandbox Code Playgroud)

在该行print(r, end = ''),eclipse报告语法错误 - Syntax error while detecting tuple.但是,该程序运行完美.

为什么会发生这种情况,如何解决错误?

Rob*_*rto 23

您需要Grammar Version在Eclipse中指定正确的.请参阅此处:Python3中的print函数

Grammar Version你的设置是3.3吗?步骤 - 项目>属性> Python解释器/语法.您可能必须重新启动Eclipse才能查看更改.

  • 我弄错了.我去了windows>首选项并在那里设置了python INTERPRETER.它应该是Project> Properties> Python Interpreter/Grammar.我不得不重启Eclipse以查看更改. (4认同)