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子句,只要有错误发生,程序会不断要求重新输入
最新推荐文章于 2024-06-25 16:32:21 发布