# python 异常 # /usr/sbin/py/python # -*-coding:utf8-*- # 语法 try: 1 / 0 # 代码块 except Exception as ex: # 异常类型 print("error", ex) # 自定义异常 class myException(BaseException): def __init__(self,message): self.message =message print(myException("error")) # raise myException("wrong!") # 断言 assert def getNumber(): return 1 result = getNumber() assert result ==5
python 26 异常
最新推荐文章于 2023-08-22 14:39:43 发布