基本上,我想用Python来读取CPU的温度。请用通俗的语言解释,因为我以前从未在Windows上做过这个,也没有与
wmi
一起工作过。
这就是我目前的情况。
import wmi
w = wmi.WMI(namespace="root\wmi")
temperature_info = w.MSAcpi_ThermalZoneTemperature()[0]
print temperature_info.CurrentTemperature
(我从这个主题中得到这个代码。在python中访问CPU温度)
However, on running the script, I get this error:
Traceback (most recent call last):
File "C:\Users\Ryan\Desktop\SerialSystemMonitor", line 4, in <module>
temperature_info = w.MSAcpi_ThermalZoneTemperature()[0]
File "C:\Python27\lib\site-packages\wmi.py", line 819, in query
handle_com_error ()
File "C:\Python27\lib\site-packages\wmi.py", line 241, in handle_com_error
raise klass (com_error=err)
x_wmi: <x_wmi: Unexpected COM Error (-2147217396, 'OLE error 0x8004100c', None, None)>
我怎么做才能让它发挥作用呢?