程序员最近都爱上了这个网站  程序员们快来瞅瞅吧!  it98k网:it98k.com

本站消息

站长简介/公众号

  出租广告位,需要合作请联系站长

+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

PYTHON异常处理

发布于2019-08-06 10:13     阅读(1062)     评论(0)     点赞(4)     收藏(0)


# 异常处理
'''异常处理格式
try:
    程序
except Exception as 异常名称:
    异常处理部分
'''
try:
    for i in range(0,10):
        print(i)
        if (i==4):
            print(kkk)
    print("hello")
except Exception as err:
    print(err)

0
1
2
3
4
name 'kkk' is not defined

 

# 异常后的程序继续
for i in range(0,10):
    try:
        print(i)
        if (i==4):
            print(kkk)
    except Exception as err:
        print(err)
print("hello")

0
1
2
3
4
name 'kkk' is not defined
5
6
7
8
9
hello



所属网站分类: 技术文章 > 博客

作者:sdhjsdh

链接:https://www.pythonheidong.com/blog/article/7516/427f13dc882466680d19/

来源:python黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

4 0
收藏该文
已收藏

评论内容:(最多支持255个字符)