import os os.system("taskkill /F /IM python.exe")#旧版
os.system("taskkill /F /IM py.exe")#3.7.3
按键盘一建停止所有python进程
from pynput.keyboard import Listener import os def press(key): if key.char=='1': os.system("taskkill /F /IM py.exe") else: print('按了什么鬼') with Listener(on_press = press) as listener: listener.join()
模拟一个py进程
i=0 input() while True: i+=1 print(str(i))