我是靠谱客的博主 失眠香菇,这篇文章主要介绍python循环判断异常(异常处理),现在分享给大家,希望可以做个参考。

#循环只有在没有异常的情况下才会退出

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循环判断异常(异常处理)内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(51)

评论列表共有 0 条评论

立即
投稿
返回
顶部