name exit is not defined in python

前端 未结 2 660
太阳男子
太阳男子 2021-01-05 03:39

The following is the code. When I run, I got an error message, saying that \"name exit is not defined\". Could anyone tell me why? Thanks very much for your time and attent

2条回答
  •  囚心锁ツ
    2021-01-05 04:31

    If you imported sys then use sys.exit(0) - change 0 with any result code you want to exit with. I had the same issue that before compilation when running from .py file exit(0) worked well but after compiling to .exe it gave me an error. I had to change exit(0) to sys.exit(0) and it worked.

提交回复
热议问题