How to stop/terminate a python script from running?

后端 未结 16 1749
-上瘾入骨i
-上瘾入骨i 2020-12-02 13:46

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条回答
  •  失恋的感觉
    2020-12-02 14:34

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

    Note: In order to use the sys.exit(), you must import it: import sys

提交回复
热议问题