Benefit from the help of this module, where I recommend one hand.
https://pythonhosted.org/psutil/#processes
Psutil is a python-based, cross-platform System Information monitoring module. Under Python, we can use it to monitor, detect, and limit the use of system resources. It provides a command function similar to a set of consoles, such as ps.netstat.ifconfig and so on. The system currently supported by this module has Windows/osx/linux/freebsd/sun Solaris. 32, 64-bit support. The Python environment is 2.6-3.5.
Here I show you how to locate a target process:
in [+]: for proc in Psutil.process_iter (): ....: try: .... : if Proc.name () and ' Target process ' in Proc. Name (): # Here I'm going to make sure that name is not none because the process may suddenly close .... : print (proc.pid) ... .: except Psutil. Nosuchprocess: .... : Pass
Psutil a python-based cross-platform system Information tracking module