码迷,mamicode.com
首页 > 编程语言 > 详细

Python 之 程序异常处理

时间:2019-02-21 17:25:31      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:cep   代码   expec   name   author   异常   dex   int   exce   

代码
#Author Kang

try:
    name = [1,2,3]
    print(name[2])   
    print(name[3])   #代码发生错误,执行Expection
except Exception as e:    #抓取所有错误
    print("错误信息:",e)

结果:
3
错误信息: list index out of range

Python 之 程序异常处理

标签:cep   代码   expec   name   author   异常   dex   int   exce   

原文地址:https://blog.51cto.com/12965094/2353092

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!