找传奇、传世资源到传世资源站!

CPU指定进程监测工具含源码

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

from clipboard
# -*- coding:UTF-8 -*-import psutilimport time,msvcrt# 定义一个进程列表process_lst = []def getProcess(pName): # 获取当前系统所有进程id列表 all_pids = psutil.pids() # 遍历所有进程,名称匹配的加入process_lst for pid in all_pids: p = psutil.Process(pid) if (p.name() == pName): process_lst.append(p) return process_lst# 获取进程名位Python的进程对象列表# Name = input('进程名:')process_lst = getProcess(input('进程名:'))for process_instance in process_lst: i = 1 while i < 1000000: cpu_count = process_instance.cpu_percent(None) time_count = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())) cpu_name = 'CPU利用率:' # print(cpu_name) print(time_count) print("CPU利用率: {:.2f}" .format(cpu_count)) with open('C:\\CPU_record.txt', 'a') as f: f.write(time_count "\n" cpu_name str(cpu_count) "\n") time.sleep(1) i = 1 print(ord(msvcrt.getch()))

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复