python 无法识别“quit()”

问题描述 投票:0回答:1

我已经在 DOS 窗口中启动了 python。它显示“Python 3.12.0”...... 但如果我输入“quit()”,我会收到消息:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'quit' is not defined

现在我无法退出Python。为什么?

python exit
1个回答
0
投票

在 Python 中,您可以通过键入

exit()
或按 Ctrl + Z 后按 Enter(在 Windows 上)退出解释器。

尝试使用

exit()
而不是
quit()
在 DOS 窗口中退出 Python 解释器。

您也可以使用

exit(0)
退出 Python 解释器。

© www.soinside.com 2019 - 2024. All rights reserved.