i'm having some trouble getting my head around python i'm sure it's something simple but i just can't get it to work.
What i'm trying to do is start my script with default variables. once it's processed then go to sleep for a set amount of time - then loop back through the script keeping any variables it's updated ( if any )
i can get it to work with the looping and i can get my counts to increase however i can't get my variable of date_time to update to the current time on the loop as it holds the time from when the script very first ran.
Here is a base code I've been playing with to try and get to work with my main code but i cant get the base code to work the way i want it too
date_time = datetime.datetime.now()
redsent_time = '00:00:00.00'
f = '%H:%M:%S.%f'
tred = redsent_time
tred2 = date_time.time()
tred3 = str(tred2) #converts tred2 into a sting value instead of a command
d1 = datetime.datetime.strptime(tred, f)
d2 = datetime.datetime.strptime(tred3, f)
counter = 0
if ((d2-d1).total_seconds()) >= 1:
counter += 1
while exec_code(): pass
The result looks like this
so you can see the time difference from midnight to my current time is always the same even though for each count 10 seconds has passed.