异常处理
Posted sunbinary
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了异常处理相关的知识,希望对你有一定的参考价值。
try: print("-------") open(‘123.txt‘, ‘r‘) except (IOError, NameError): print("######") pass try: open(‘1.txt‘,‘r‘) except: print("异常") try: # open(‘1.txt‘, ‘r‘) print("1") except Exception as result: print("异常") print(result) else: print("没有异常") finally: print("finally") print("-----------------------") try: try: print(1/0) except ValueError as e: print(e) except ZeroDivisionError as e: print(e) print("-----------------------") try: try: 1 / 0 except ZeroDivisionError as e: print("无能为力,不能处理") raise except ZeroDivisionError as e: print(e)
以上是关于异常处理的主要内容,如果未能解决你的问题,请参考以下文章
java.util.MissingResourceException: Can't find bundle for base name init, locale zh_CN问题的处理(代码片段