I'm pretty new to python and I'm writing a script to read pressures using a sensor with the time of the reading. I don't know how to add this to a dictionary so the time is the unique identifier (the key). Can anyone help?
The last line of code "print(read_pressures)" just displays the last reading. I want to show all 100 readings. Any help appreciated.
import json
import time
from decimal import Decimal
count = 0
while (count < 100):
current_time=time.time()
read_pressures = {'Time': current_time, 'pressure': 7} # the pressure value will be changed to the variable with the current pressure.
time.sleep(0.01)
count = count + 1
print(count ,read_pressures) #
print(read_pressures)
Thanks