PYTHON异常处理
发布时间:2022-08-09 11:09:35 所属栏目:Linux 来源:互联网
导读:# 异常处理 异常处理格式 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 复制代码 #
|
# 异常处理 '''异常处理格式 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 (编辑:哈尔滨站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
