本章节介绍异常处理,分享给刚学python的小伙伴,一起学习,共同进步
try:
open("zip.text")
except KeyError as e:
print("没有这个key",e)
except IndexError as e:
print("列表操作错误", e)
except BaseException as e:
print("未知错误", e)
else:
print("一切正常")
finally:
print("不管有没有错,都执行")