标签:image div rom name ISE code from col 技术分享
1 """ 2 自定义异常 3 """ 4 class MyException(Exception): # 继承异常类 5 def __init__(self, name, reason): 6 self.name = name 7 self.reason = reason 8 9 from datetime import datetime 10 try: 11 if str(datetime.now()) > "2018": 12 raise MyException("TimeoutException", "time is overtime...") 13 except MyException as e: 14 print(e.name +":"+e.reason) 15 16 """ 17 抛出异常 18 """ 19 try: 20 6/0 21 raise 22 except Exception as e: 23 print(e)
结果:
标签:image div rom name ISE code from col 技术分享
原文地址:https://www.cnblogs.com/yszd/p/10146178.html