python中exit()和quit()有什么区别?

import pygame
from pygame.locals import *

pygame.init()
screen = pygame.display.set_mode((800, 600)) 

for event in pygame.event.get():
    if event.type == QUIT:
            exit()
    if event.type == QUIT:
            quit()

两个都可以实现退出窗口,到底有什么区别呢???

你这回答跟题目对不上呀

exit是交互式shell的助手 - sys.exit旨在用于程序中。

该site模块(在启动过程中自动导入,除了-S给出命令行选项外)将多个常量添加到内置名称空间(例如exit)。它们对交互式解释器外壳非常有用,不应在程序中使用。

从技术上讲,他们的工作基本相同:提高SystemExit。sys.exit在sysmodule.c中是这样做的:

static PyObject *
sys_exit(PyObject self, PyObject *args)
{
PyObject *exit_code = 0;
if (!PyArg_UnpackTuple(args, "exit", 0, 1, &exit_code))
return NULL;
/
Raise SystemExit so callers may catch it or clean up. */
PyErr_SetObject(PyExc_SystemExit, exit_code);
return NULL;
}
虽然分别exit在site.py和_sitebuiltins.py中定义。

class Quitter(object):
def init(self, name):
self.name = name
def repr(self):
return 'Use %s() or %s to exit' % (self.name, eof)
def call(self, code=None):
# Shells like IDLE catch the SystemExit, but listen when their
# stdin wrapper is closed.
try:
sys.stdin.close()
except:
pass
raise SystemExit(code)
builtin.quit = Quitter('quit')
builtin.exit = Quitter('exit')
请注意,还有第三个退出选项,即os._exit,它在不调用清理处理程序,刷新stdio缓冲区等的情况下退出(并且通常只应在a后的子进程中使用fork())。
转自:https://cloud.tencent.com/developer/ask/137048