Heim > Fragen und Antworten > Hauptteil
黄舟2017-04-17 17:42:38
except里再try。
try:
语句A
except Exception as e:
try:
语句A
except Exception as e:
# 继续
但这样很蠢,如果你真想实现无限循环捕获异常的话,这么写吧:
def func():
try:
语句A
except Exception as e:
return False
else:
return True
while not func():
pass # Or do something