**已关闭。**此问题不符合Stack Overflow guidelines。目前不接受答复。
这个问题似乎不是关于在help center定义的范围内编程。
昨天关门了。
Improve this question
我写了下面的代码。
try:
print(42/0)
continue
except (ZeroDivisionError):
print("Zero division")
except:
print("You made a mistake")
except (ValueError):
print("Boo!")
代码失败,出现错误
语法错误:“continue”在循环中不正确
这是continue
的正确语法,没有缩进错误。
错误的含义是什么?
1条答案
按热度按时间svmlkihl1#
你得到这个错误的原因是因为你不需要一个带有
try
和except
的continue语句。如果它运行try
中的代码,它将不会运行except
中的代码。