class getoutofloop(Exception):
pass
try:
for i in range(5):
for j in range(5):
for k in range(5):
if i==j==k==3:
raise getoutofloop() #raise 抛出异常对象,退出多重循环,不会继续执行try中语句
else:
print(i,j,k)
except getoutofloop:
print("抛出异常对象")
print("done")
原文:https://www.cnblogs.com/lilysuper/p/15034713.html