看板 Python 關於我們 聯絡資訊
大家好, 目前看彭彭老師的youtube videos學習python,目前學習到if判斷式 我跟著老師打的程式出現了錯誤無法正確跑完,煩請大家教導我哪裡出錯,謝謝 以下為程式碼 x=int(input('enter a number: ')) y=int(input('enter a number: ')) op=input('enter an operator: +, -, *, /: ') if op=='+': print(x+y) elif op=='-': print(x-y) elif op=='*': print(x*y) elif op=='/': print(x/y) else: print('not an operator') 輸入完兩個數值及運算子後,出現以下訊息, enter a number: 6 enter a number: 8 enter an operator: +, -, *, /: / Traceback (most recent call last): File "condition2.py", line 3, in <module> op=input('enter an operator: +, -, *, /: ') File "<string>", line 1 / ^ SyntaxError: unexpected EOF while parsing 請問我改如何修改讓程式繼續跑下去呢? 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 47.184.77.89 (美國) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1588913796.A.A72.html
annheilong: 你是不是用到 Python 2 了? Python 3 才會正常喔 05/08 13:25
kenduest: 正在用 python2 ? 請務必改用 python3 來學習 05/08 13:28
xup6yvu06: 我下載的是3.8 05/08 13:33
cuteSquirrel: 用 python 3吧 官方的維護主力在3.X 以後的版本 05/08 13:45
jezi1878: 你是不是用蘋果電腦,它本身內建2.7版本,就算灌了3.6 05/08 13:48
jezi1878: 版本。設定值沒設好,還是用2.7在跑 05/08 13:48
xup6yvu06: 對,我剛剛檢查了,terminal顯示的是python2,我以為我 05/08 13:54
xup6yvu06: 安裝好了,感謝大家提點 05/08 13:54
MAGICXX: 我還是習慣用python2.7...Y 05/08 18:01
salmon12706: 工研院人工智慧課程推薦https://reurl.cc/4RDRaK 06/29 16:25