I would like to execute one line at a exact second, say 14:02:08.000000. Here's the code I used to do so:
now = datetime.now()
while now.strftime("%f")!= "000000":
now = datetime.now()
run_the_code
This method works fine on my laptop. However, when i use this code on my raspberry Pi, which has a much slower CPU, it takes quite a while to 'catch' the case of %f == 000000.
I guess the sched method would be faster, but I don't know how to make it run on the exact time of %f == 000000.
Is there another way to work around it on my slow RPi? Thanks!