進(jìn)程監(jiān)控在python怎么實(shí)現(xiàn)?
提問人:楊紫紅發(fā)布時(shí)間:2020-11-24
腳本如下:
#讀取進(jìn)程pid,名稱,可執(zhí)行路徑
pid = psutil.pids()
for k,i in enumerate(pid):
try:
proc = psutil.Process(i)
print k,i,"%.2f%%"%(proc.memory_percent()),"%",proc.name(),proc.exe()
except psutil.AccessDenied :
print "psutil.AccessDenied"
#讀取進(jìn)程pid,名稱,可執(zhí)行路徑
pid = psutil.pids()
for k,i in enumerate(pid):
try:
proc = psutil.Process(i)
print k,i,"%.2f%%"%(proc.memory_percent()),"%",proc.name(),proc.exe()
except psutil.AccessDenied :
print "psutil.AccessDenied"
繼續(xù)查找其他問題的答案?
相關(guān)視頻回答
點(diǎn)擊加載更多評論>>