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