开发者

How can I get the CPU temperature in Python? [duplicate]

This question already has answers here: 开发者_高级运维 Closed 12 years ago.

Possible Duplicate:

Getting CPU temperature using Python?

What is the simplest method of going about this? Also preferably in Celsius.


There's no standard Python library for this, but on various platforms you may be able to use a Python bridge to a platform API to access this information.

For example on Windows this is available through the Windows Management Instrumentation (WMI) APIs, which are available to Python through the PyWin32 library. There is even a Python WMI library which wraps PyWin32 to provide a more convenient interface. To get the temperature you'll need to use one of these libraries to access the root/WMI namespace and the MSAcpi_ThermalZone Temperature class. This gives the temperature in tenths of a Kelvin, so you'll need to convert to Celsius by deducting 2732 and dividing by 10.

Not sure about about Linux or Mac I'm afraid, but there may be equivalent libraries you can use. A quick Google indicated that /proc/acpi/thermal_zone/THM/temperature may be what yoiu're after if your distro supports the proc virtual filesystem for accessing kernel information.


On Linux, that info is in /proc/acpi/thermal_zone/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜