Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Target item in python library

I am trying to print just the current temperature only from the output using psutil on my raspberry pi with python.
Any help in altered inputs would be greatfully appreciated.

Input

Import psutil

print ((psutil.sensors_temperatures())

Output

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

{'cpu_thermal': [shwtemp(label='', current=36.998, high=None, critical=None)]}

I have tried several alteration to the input statement but not getting the output required

psutil.sensors_temperatures().current

psutil.sensors_temperatures().cpu_thermal.current

>Solution :

# get the temperature
cpu_temp = psutil.sensors_temperatures()["cpu_thermal"][0]
print(cpu_temp.current)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading