用python获取电脑cpu温度代码

用python获取电脑cpu温度代码,第1张

from __future__ import division

import os

from collections import namedtuple

_nt_cpu_temp = namedtuple('cputemp', 'name temp max critical')

def get_cpu_temp(fahrenheit=False):

"""Return temperatures expressed in Celsius for each physical CPU

installed on the system as a list of namedtuples as in:

>>> get_cpu_temp()

[cputemp(name='atk0110', temp=320, max=600, critical=950)]

"""

# >

cpu:

>>> import psutil

>>> psutilcpu_times()

scputimes(user=396146, nice=169729, system=2150659, idle=16900540, iowait=62959, irq=00, softirq=1942, steal=00, guest=0, nice=00)

>>>

>>> for x in range(3):

     psutilcpu_percent(interval=1)

40

59

38

>>>

>>> for x in range(3):

     psutilcpu_percent(interval=1, percpu=True)

[40, 69, 37, 92]

[70, 85, 24, 21]

[12, 90, 99, 72]

>>>

>>>

>>> for x in range(3):

     psutilcpu_times_percent(interval=1, percpu=False)

scputimes(user=15, nice=00, system=05, idle=965, iowait=15, irq=00, softirq=00, steal=00, guest=00, guest_nice=00)

scputimes(user=10, nice=00, system=00, idle=990, iowait=00, irq=00, softirq=00, steal=00, guest=00, guest_nice=00)

scputimes(user=20, nice=00, system=00, idle=980, iowait=00, irq=00, softirq=00, steal=00, guest=00, guest_nice=00)

>>>

>>> psutilcpu_count()

4

>>> psutilcpu_count(logical=False)

2

>>>

内存:

>>> psutilvirtual_memory()

svmem(total=8374149120L, available=2081050624L, percent=751, used=8074080256L, free=300068864L, active=3294920704, inactive=1361616896, buffers=529895424L, cached=1251086336)

>>> psutilswap_memory()

sswap(total=2097147904L, used=296128512L, free=1801019392L, percent=141, sin=304193536, sout=677842944)

>>>

读取短信需要在相应的手机上读取呀

由于工作需要,登录网站需要用到验证码。最初是研究过验证码识别的,但是总是不能获取到我需要的那个验证码。直到这周五,才想起这事来,昨天顺利的解决了。

下面正题:

Python版本:343

所需要的代码库:PIL,selenium,tesseract

先上代码:

#coding:utf-8

import subprocess

from PIL import Image

from PIL import ImageOps

from selenium import webdriver

import time,os,sys

def cleanImage(imagePath):

image = Imageopen(imagePath) #打开

image = imagepoint(lambda x: 0 if x<143 else 255) #处理上的每个像素点,使上每个点“非黑即白”

borderImage = ImageOpsexpand(image,border=20,fill='white')

borderImagesave(imagePath)

def getAuthCode(driver, url=">

PC上的(包括台式机和笔记本)USB接口都只有Host模式,如果要两个USB设备通信,必须一个是Host另一个是Device,否则硬件都无法工作,更别提通信了,并且,任何编程语言都不行。

如果其中一端是手机、平板等移动设备,并且确认支持USB OTG模式的话,还可以通过OTG来通信,但涉及的东西太多:USB协议、设备协议、驱动开发、设备模拟等等,付出如此大的代价不值得。

最近一直在琢磨写一个有点烦人的小爬虫,结果琢磨着,就花了一点点时间,写了这样一个“不友好”的,被许多人讨厌的爬虫

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9763144.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-01
下一篇2023-05-01

发表评论

登录后才能评论

评论列表(0条)

    保存