As described in Doing something after running a function n times, I have a project about water spillage. I've come to the conclusion that i want to only send a mail, if temp_diff
is greater than a given value after a period of time, lets say 24 hours.
while True:
AntalMaalinger = 10 # Number of samples
Maalinger = [] # List with samples
while AntalMaalinger > 0:
AntalMaalinger -= 1
temp_diff_var = KodeVandDef.temp_diff() # ligger funktionen i en variabel
Maalinger.append(temp_diff_var) # Tilf?jer resultatet til listen
print(KodeVandDef.aflaes_temp())
print("Temperaturforskellen er: %.3f grader" % temp_diff_var)
logfil.write("%s, %s
" % KodeVandDef.aflaes_temp())
logfil.write("Temperaturforskellen er: %.3f grader
" % temp_diff_var)
# Median = statistics.median(Maalinger)
if all(x > 0 for x in Maalinger): # Or if 0 < Median:
KodeVandDef.send_mail("SENDER", "PASSWORD", "RECEIVER", "Besked fra din vandm?ler",
"Afl?bsr?r: Temperaturforskellen er lige nu %.3f grader, og er h?jere end gr?nsen . "
"Handling "
"p?kr?vet!" % (
Maalinger[-1])) # Or % Median
Do I need a list at all?
Apparantley it's not allowed in our project to have the functions in the same codefile, so I've made a seperate file for the functions.
And I don't know if it's right to ask a question by refering to another.
question from:
https://stackoverflow.com/questions/65918808/is-temp-diff-still-above-threshold-after-a-specific-period-of-time 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…