#没有异常处理
num = int('yyt')
print(num) #报错
#异常处理
try:
num = int('yyt') #try里的代码是受保护的
print(num)
except Exception as e:
print(e) #输出invalid literal for int() with base 10: 'abc',程序正常运行
eg:
if debug:
tracked_bb, exec_times = tracker.run(seq, debug=debug)
else:
try:
tracked_bb, exec_times = tracker.run(seq, debug=debug)
except Exception as e:
print(e)
return
python异常处理
最新推荐文章于 2025-03-26 20:05:14 发布
该博客围绕Python异常处理展开,在信息技术领域,异常处理是保障程序稳定运行的关键。Python提供了丰富的异常处理机制,能帮助开发者有效应对程序运行中出现的各种错误,确保程序的健壮性和可靠性。
7330

被折叠的 条评论
为什么被折叠?



