I want to print time if the value is repeated more then 10 second

63 Views Asked by At

The code below will start to print the time if:

time.time() - start_time) >10 and Total_ratio > 5.0

but its only works once. How to make it work for every 10 seconds because its works only once.

    end_time = time.time() + 5
    if ((time.time() - start_time) >10 and Total_ratio > 5.0 ):
            cv2.putText(frame, "Closed", (50, 150), font, 7, (0, 255, 255), thickness=3)
            print(ctime())
           
            if time.time() > end_time:
                break
1

There are 1 best solutions below

0
On

Change as required:

import threading
import time

def printit():
   now = time.strftime("%I:%m:%S %p")
   threading.Timer(5.0, printit).start()
   print (now)

printit()