使用自定义异常可以跳出深层嵌套循环、看我做过的例子:
class FoundException(Exception): pass
try:
for row,record in enumerate(table):
for columu,field in enumerate(record):
for index,item in enumerate(field):
if item == target:
raise FoundException()
except FoundException:
print ("found at ({0},{1},{2})".format(row,column,index))
else:
print ('not found')