6
我在Python 3.3中有一個try-except塊,我希望它無限期地運行。如何重複try-except塊
try:
imp = int(input("Importance:\n\t1: High\n\t2: Normal\n\t3: Low"))
except ValueError:
imp = int(input("Please enter a number between 1 and 3:\n> ")
目前,如果用戶輸入一個非整數,將工作按計劃進行,但如果他們要重新進入,它只是再次提高ValueError異常和崩潰。
解決此問題的最佳方法是什麼?