异常处理

Posted on 2019-03-02 13:50  心酒  阅读(93)  评论(0编辑  收藏  举报

try:

  检测范围 #代码

except 错误代码 as reason:

  print('文件出错了,原因是:' + str(reason))

 

finally: 这个命令可以在出错后依旧执行可以运行的代码

异常处理语句 try: 可以接else和with