摘要: 1 BaseException 2 +-- SystemExit 3 +-- KeyboardInterrupt 4 +-- GeneratorExit 5 +-- Exception 6 +-- StopIteration 7 +-- StopAsyncIteration 8 +-- ArithmeticError 9 ... 阅读全文
posted @ 2017-05-07 17:21 道高一尺 阅读(333) 评论(0) 推荐(0)
摘要: 进入时,调用对象的__enter__ 退出时,调用对象的__exit__ 阅读全文
posted @ 2017-05-07 17:05 道高一尺 阅读(168) 评论(0) 推荐(0)
摘要: 1 import logging 2 3 def foo(s): 4 return 10 / int(s) 5 6 def bar(s): 7 return foo(s) * 2 8 9 def main(): 10 try: 11 bar(0) 12 except Exception as e: 13 ... 阅读全文
posted @ 2017-05-07 16:51 道高一尺 阅读(182) 评论(0) 推荐(0)
摘要: 1 import sys 2 try: 3 a = 3 4 assert a > 4 5 except: 6 exc = sys.exc_info()#返回异常的元祖 7 print (exc) 阅读全文
posted @ 2017-05-07 15:51 道高一尺 阅读(528) 评论(0) 推荐(0)