028-86922220
建站资讯

网站建设资讯

为你提供网站建设行业资讯、网站优化知识、主机域名邮箱、网站开发常见问题等。

Python之程序异常处理

代码

#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之程序异常处理
转载源于:http://whjierui.cn/article/gsjhoe.html

其他资讯