怎么用python实现电脑cpu温度监控
发布网友
发布时间:2022-05-02 10:19
我来回答
共1个回答
热心网友
时间:2022-06-19 06:10
def monitor_process(key_word, cmd):
p1 = subprocess.Popen(['ps',
'-ef'], stdout=subprocess.PIPE)
p2 = subprocess.Popen(['grep', key_word],
stdin=p1.stdout, stdout=subprocess.PIPE)
p3 = subprocess.Popen(['grep',
'-v', 'grep'], stdin=p2.stdout, stdout=subprocess.PIPE)
lines = p3.stdout.readlines()
if len(lines) > 0:
return
sys.stderr.write('process[%s] is lost, run [%s]\n' % (key_word,
cmd))
subprocess.call(cmd, shell=True)追问这是python2.7执行的吗?朋友