python简说(二十六)异常

# try:
# res = 1 / 0
# except ZeroDivisionError as e:
# print('出错啦,除数不能为0',e) # l = list()
# l.append(1)
# d = dict()
# # d['name']='abc'
# try:
# print(d['name'])
# print(l[-1])
# except IndexError as e:
# print('出错了,下标越界',e)
# except KeyError as e:
# print('字典key不存在',e)
# except Exception as e:
# print('未知异常',e)
# else:
# print('没有出现异常。。。')
# finally:
# print('什么时候都执行finally') 主动抛出来一个异常,不往下走了
raise NumberError('输入的数字不对')
上一篇:第一次极限测试效果图


下一篇:Dev gridControl z