捕获异常的两种方式
捕獲異常的兩種方式方法一
#coding=utf-8
import systry:with open("ddd.txt", "r") as f:data = f.read()print data
except:err = sys.exc_info()print errsys.exc_info()返回三元組,分別是,異常類型、異常值、異常追溯地址方法二
#coding=utf-8try:with open("ddd.txt", "r") as f:data = f.read()print data
except Exception as e:print str(e)
?
轉載于:https://www.cnblogs.com/themost/p/9261531.html
總結
- 上一篇: 60、70岁程序员工资暴涨!原因让80/
- 下一篇: sql常识