x = int(input("give me a number1:"))
y = int(input("give me a number2:"))
op = input("give me op")
if op == "+":
print(x+y)
elif op == "-":
print(x-y)
elif op == "*":
print(x*y)
elif op == "/":
print(x/y)
else:
print("sorry")
====
上述程式码执行时,会出现"SyntaxError: unexpected EOF while parsing"
但我把第3行改成
raw_input("give me op")
就可以了执行了
(我是从stackoverflow找到此方法的,但我搞不懂原因,有大神可分享)
参考网址:https://stackoverflow.com/questions/17611391/python-invalid-syntax-on-line-1-file-string