本文介绍了在Mac上的终端中停止python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Mac的终端中使用python,键入

Using python in terminal on a Mac, type

ctrl-z

将停止python,但不退出它,给出如下输出:

will stop the python, but not exit it, giving output like this:

>>>
[34]+  Stopped                 python

如您所见,我已经停止了34个python调用.

As you can see, I have stopped 34 python calls.

虽然我可以使用

>>> exit()

要退出python,问题是:

to exit python, the questions are:

  1. 在终端中是否有短键真正退出(而不只是停止)python?还有,为什么

  1. Is there a short-key to really exit (not just stop) python in terminal? and, why

ctrl-c

不起作用?

如何杀死所有停止的python?

How do I kill all the stopped python?

顺便说一句,我如何用键盘外观键入'ctrl-c'和其他热键?

BTW, how could I type 'ctrl-c' and other hotkeys with a keyboard look?

谢谢!

推荐答案

+ ->定义EOF(文件末尾).

+ -> Defines EOF (End of File).

+ ->将终止大多数作业.

+ -> Will terminate most jobs.

但是,如果您编写了依次调用其他python程序的python包装程序,则Ctrl-c只会停止当前正在运行的作业.包装程序将继续运行.最坏的情况是,您可以执行以下操作:

If, however you have written a python wrapper program that calls other python programs in turn, Ctrl-c will only stop the the job that is currently running. The wrapper program will keep running. Worst case scenario, you can do this:

打开:应用程序->实用程序->活动监视器,找到标记为python的进程,在活动监视器中突出显示该进程,然后单击退出进程".

Open up: Applications -> Utilities -> Activity Monitor, Find the process labeled as python, highlight it in the activity monitor then click on "Quit Process".

这三个建议在大多数情况下都可以使您的程序停止运行.

These three suggestions should work for most situations where you want a program to stop.

这篇关于在Mac上的终端中停止python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 05:48