while True:
try:
x=int(input('Please input a number for x:'))
y=int(input('Please input a number for y:'))
print(x/y)
except:
print ('fuck you,try again')
else:break
try/exception加个else子句,只要有错误发生,程序会不断要求重新输入
最新推荐文章于 2022-02-25 18:22:52 发布