Is there a method that tells my program to quit?

后端 未结 5 1131
不知归路
不知归路 2020-12-25 10:21

For the \"q\" (quit) option in my program menu, I have the following code:

elif choice == \"q\":
    print()

That worked all right until I

5条回答
  •  余生分开走
    2020-12-25 10:55

    Please note that the solutions based on sys.exit() or any Exception may not work in a multi-threaded environment.

    Since exit() ultimately “only” raises an exception, it will only exit the process when called from the main thread, and the exception is not intercepted. (doc)

    This answer from Alex Martelli for more details.

提交回复
热议问题