捕获异常的两种方式方法一 #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)