异常处理
try:
"被监测的代码(可能会出错的代码)"
except: 错误类型 as e:
"针对上述错误类型制定的方案"
print(e)
# 万能异常
except Exception as e:
print(e)
小练习
# 练习题 利用while循环,迭代器对象和异常监测来完成for的功能
l1=[11,22,33,44,55,66,77,88,99]
res = l1.__iter__()
while True:
try:
ret=res.__next__()
print(ret)
except Exception as e:
break
标签:__,练习,except,while,循环,print,异常,底层 From: https://www.cnblogs.com/abc683871/p/17615558.html