錯誤姿勢:
#連續輸入多個數 x = eval(input("請輸入1個數")) print(x)
請輸入1個數
Traceback (most recent call last):
File "D:/Python/day2/input.py", line 2, in <module>
x = eval(input("請輸入1個數"))
File "<string>", line 0
^
SyntaxError: unexpected EOF while parsing
正確姿勢:
#連續輸入多個數 try: x, y, z = eval(input("請輸入3個數,分割如1,2,3")) print(x, y, z) except: print("輸入有誤如1,2,3") finally: try: x = eval(input("請輸入1個數")) print(x) except: print("輸入有誤")