#循环只有在没有异常的情况下才会退出
while True:
try:x = input('Enter the first number:')
y = input('Enter the second number:')
value = x/y
print 'x/y is ', value
except Exception,e:
print 'Invalid input:',e
print 'Please try again'
else:
break
测试结果:
最后
以上就是失眠香菇最近收集整理的关于python循环判断异常(异常处理)的全部内容,更多相关python循环判断异常(异常处理)内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复