How to stop/terminate a python script from running

2020-01-30 08:00发布

I wrote a program in IDLE to tokenize text files and it starts to tokeniza 349 text files! How can I stop it? How can I stop a running Python program?

16条回答
仙女界的扛把子
2楼-- · 2020-01-30 08:31

When I have a python script running on a linux terminal, CTRL + \ works. (not CRTL + C or D)

查看更多
看我几分像从前
3楼-- · 2020-01-30 08:31

Press Ctrl+Alt+Delete and Task Manager will pop up. Find the Python command running, right click on it and and click Stop or Kill.

查看更多
【Aperson】
4楼-- · 2020-01-30 08:33

Control+D works for me on Windows 10. Also, putting exit() at the end also works.

查看更多
Animai°情兽
5楼-- · 2020-01-30 08:35

you can also use the Activity Monitor to stop the py process

查看更多
叼着烟拽天下
6楼-- · 2020-01-30 08:35

exit() will kill the Kernel if you're in Jupyter Notebook so it's not a good idea. raise will stop the program.

查看更多
\"骚年 ilove
7楼-- · 2020-01-30 08:38

You can also do it if you use the exit() function in your code. More ideally, you can do sys.exit(). sys.exit() might terminate Python even if you are running things in parallel through the multiprocessing package.

查看更多
登录 后发表回答