请问以下代码:
while True:
try:
print("waiting for 10 seconds...")
continue
print("never show this")
finally:
time.sleep(10)
始终打印“等待10秒......”的消息,睡10秒钟,然后再做一次?换句话说,做声明 finally
即使循环是,子句也会运行 continue
-ed?
请问以下代码:
while True:
try:
print("waiting for 10 seconds...")
continue
print("never show this")
finally:
time.sleep(10)
始终打印“等待10秒......”的消息,睡10秒钟,然后再做一次?换句话说,做声明 finally
即使循环是,子句也会运行 continue
-ed?
来自 python docs:
当在try ... finally语句的try套件中执行return,break或continue语句时,finally子句也会在出路时执行。在continue子句中,continue语句是非法的。 (原因是当前实施存在问题 - 将来可能会解除此限制)。