Using python in terminal on a Mac, type
ctrl-z
will stop the python, but not exit it, giving output like this:
>>>
[34]+ Stopped python
As you can see, I have stopped 34 python calls.
Although I could use
>>> exit()
to exit python, the questions are:
Is there a short-key to really exit (not just stop) python in terminal? and, why
ctrl-c
does NOT work?
How do I kill all the stopped python?
BTW, how could I type 'ctrl-c' and other hotkeys with a keyboard look?
Thanks!
解决方案
CTRL+d -> Defines EOF (End of File).
CTRL+c -> Will terminate most jobs.
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:
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.