巴壁虎 2020-04-29
#try/except try: pass except: pass try: pass except Exception: pass #try/except ... try: pass except (Exception1, Exception2): pass try: pass except Exception1: pass except Exception2: pass #try/except ... as ... try: pass except Exception as e: isinstance(e, Exception) except ... try: pass except (Exception1, Exception2) as e: print(e) #try/except/else try: pass except ...: pass except ... else: pass #try/finally try: pass finally: pass try: pass except ...: pass finally: pass try: pass except ...: pass except ... else: pass finally: pass
class MyException(Exception): pass
raise raise MyException raise MyException() raise MyException(‘Error‘) raise MyException from None raise MyException() from None