2017-01-16 87 views

回答

0

psutil是一個跨平臺的庫,檢索有關正在運行的進程和系統利用率的信息。

import psutil 
running_programm = "tomcat" #Whatever the name of your programm 
pythons_psutil = [] 
for p in psutil.process_iter(): 
    try: 
     if p.name() == running_programm: 
      pythons_psutil.append(p) 
    except psutil.Error: 
     pass 
if pythons_psutil : 
    print "It's running !!"