【问题标题】:How to get out of Python in Windows 10 command prompt? [duplicate]如何在 Windows 10 命令提示符下退出 Python? [复制]
【发布时间】:2025-12-20 05:00:06
【问题描述】:

我是使用命令提示符的新手,我刚刚从命令提示符执行了我的第一行代码,如下所示:

C:\Users\Michael>python
Python 3.9.5 (tags/v3.9.5:0a7dcbd, May  3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print("hello world")
hello world

我现在如何“退出”Python,以便可以运行其他命令,例如cdcpls 等?我知道我可以关闭并打开一个新的命令提示符窗口,但是是否有一个命令可以代替它?

【问题讨论】:

  • 哈哈,这真的很有趣。你可以使用exit()函数。
  • exit() 函数或Ctrl+Z
  • 我惊讶地发现这个有重复;但是无论教程让你走到这一步,肯定也解释了下一步。

标签: python windows terminal command-prompt


【解决方案1】:

只需运行exit() 即可关闭窗口。

【讨论】:

    【解决方案2】:

    先生,您可以输入exit()Ctrl+Z 并点击回车。

    【讨论】: