Python - get process names,CPU,Mem Usage and Peak Mem Usage in windows

后端 未结 3 1267
Happy的楠姐
Happy的楠姐 2020-12-14 02:55

I am wanting to get a list of all the process names, CPU, Mem Usage and Peak Mem Usage. I was hoping I could use ctypes. but I am happy to hear any other options. Thanks for

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-14 02:56

    This Python 3.3 code works for Windows 7 with UAC all the way down.

    import psutil
    import time
    
    def processcheck(seekitem):
        plist = psutil.get_process_list()
        str1=" ".join(str(x) for x in plist)
        if seekitem in str1:
            print ("Requested process is running")   
    
    processcheck("System")
    

提交回复
热议问题