# 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 异常
最新推荐文章于 2024-09-26 20:46:42 发布
261

被折叠的 条评论
为什么被折叠?



