统计Linux下的CPU状态信息
程序员文章站
2022-05-22 21:40:33
def cpu(): all_cpus=[] with open('e:/cpu.txt') as f: core={} for line in f.readlines(): ab=line.split(":") if len(ab)==2: if ab[0].strip()=='processor ......
def cpu(): all_cpus=[] with open('e:/cpu.txt') as f: core={} for line in f.readlines(): ab=line.split(":") if len(ab)==2: if ab[0].strip()=='processor': if core: all_cpus.append(core.copy()) core={} core['proc_id']=ab[1].strip() else: core[ab[0].strip()]=ab[1].strip() all_cpus.append(core.copy()) print(all_cpus) return all_cpus; if __name__ =='__main__': cpu()
上一篇: 俄罗斯人的前身是维京人吗?俄罗斯和维京人有什么关系?
下一篇: 将WSL2作为生产力工具