为什么使用Eclipse在python中收到语法错误? [英] Why am I getting a syntax error in python using Eclipse?

查看:423
本文介绍了为什么使用Eclipse在python中收到语法错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑:PYTHON 2.6 ...所以在技术上不是一个重复的问题.....



我试图找出如何在Eclipe上使用Python

解决方案

根据 python 2 ,您的代码是正确的。



正如您获得语法错误,您必须使用 python 3 。在这种情况下,您需要在 print 语句

之间添加圆括号

  print (add(1,2))


Edit: PYTHON 2.6 ... so not technically a duplicate question .....

I'm trying to figure out how to use Python on Eclipe using this tutorial but I'm stuck on part 4.Debugging. using this code:

def add(a,b):
    return a+b

def addFixedValue(a):
        y = 5
        return y +a

print add(1,2)
print addFixedValue(1)

I added a breakpoint, but still get an error:

    print add(1,2)
            ^
SyntaxError: invalid syntax

解决方案

Your code is correct according to python 2.

As you are getting syntax error, you must be using python 3. In that case, you need to add parenthesis around print statement

print (add(1,2))

这篇关于为什么使用Eclipse在python中收到语法错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆