Kill process by name?
问题 I'm trying to kill a process (specifically iChat). On the command line, I use these commands: ps -A | grep iChat Then: kill -9 PID However, I'm not exactly sure how to translate these commands over to Python. 回答1: Assuming you're on a Unix-like platform (so that ps -A exists), >>> import subprocess, signal >>> p = subprocess.Popen(['ps', '-A'], stdout=subprocess.PIPE) >>> out, err = p.communicate() gives you ps -A 's output in the out variable (a string). You can break it down into lines and