I'm trying to write a code to execute a print function at a specific local time in microsecond resolution. I'm using python 3.6. My simple code is:
from datetime import datetime
while True:
now=datetime.now()
now=(now.hour,now.minute,now.second,now.microsecond)
if now>(0,42,40,0):
print(now)
break
these are some results: for time (0,42,40,0) result is:(0, 42, 40, 255) for time (0,49,0,0) result is:(0, 49, 0, 841) for time (0,51,0,0) result is (0, 51, 30, 86). the problem is every time i run this code this code starts at different times with a random distribution in microseconds while I need the delay to be constant in 1 microsecond accuracy. my OS is Windows 10. I'll be appreciate if anybody helps me to solve this problem. thanks.