Given this output, what is the key:value pair python is using | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Given this output, what is the key:value pair python is using

I'm trying to understand how a particular python script works and this is the output when i print 'bme280_data': compensated_reading(id=ee50df9c-3aa3-4772-8767-73b6bb74f30f, timestamp=2016-11-18 17:33:28.937863, temp=20.563 °C, pressure=980.91 hPa, humidity=48.41 % rH) when I just want the temp, I can print(bme280_data.temp) is bme280 using a dictionary to store this data? This is the code: import smbus2 import bme280 port = 1 address = 0x76 bus = smbus2.SMBus(port) bme280.load_calibration_params(bus, address) bme280_data = bme280.sample(bus, address)

9th Jun 2022, 7:51 PM
David
David - avatar
4 Answers
+ 2
Seems to be object access. For humidity you can try: print(bme280_data.humidity) What do you want to achieve?
10th Jun 2022, 4:37 AM
JaScript
JaScript - avatar
+ 1
JaScript thanks for answering. Im working on a project and was just wondering how the bme280 library works and how to access the data
10th Jun 2022, 4:42 AM
David
David - avatar
+ 1
Cool project David . You get a set of sensor data. They could be stored with a time delay. And then something can be done with it. Happy coding!
10th Jun 2022, 4:51 AM
JaScript
JaScript - avatar
+ 1
I used it for the raspberry pi weather station. Has been really fun making. Just finished it today.
10th Jun 2022, 5:00 AM
David
David - avatar