Python 我退出了程序,但脚本继续运行

时间:2021-02-10 23:10:51

标签: python python-3.x pygame

我正在制作这个游戏,我希望它在我关闭窗口时退出。现在它工作得很好。窗户没有任何挣扎地关闭。但是,脚本本身继续运行,我不知道为什么。这是结束游戏的代码,我不明白为什么它不会杀死一切。有什么帮助吗?

for event in pygame.event.get():
    if event.type == pygame.QUIT:
        self.running = False
            pygame.quit()
            quit()
            sys.exit()

1 个答案:

答案 0 :(得分:1)

你做了吗

import sys

在你的脚本中?