问题
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
回答1:
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))
来源:https://stackoverflow.com/questions/41111702/why-am-i-getting-a-syntax-error-in-python-using-eclipse