Python: Using continue in a try-finally statement in a loop
问题 Will the following code: while True: try: print("waiting for 10 seconds...") continue print("never show this") finally: time.sleep(10) Always print the message "waiting for 10 seconds...", sleep for 10 seconds, and do it again? In other words, do statements in finally clauses run even when the loop is continue -ed? 回答1: From the python docs: When a return, break or continue statement is executed in the try suite of a try...finally statement, the finally clause is also executed ‘on the way out