2021年1月20日星期三

Python how to freeze program?

Note: read my comments on the provided answer, it doesn't work

I have a python program which runs every 5 seconds like this:

def main():      start_time = time.time()      while True:          if not execute_data():              break          time.sleep(5.0 - ((time.time() - start_time) % 5.0))  

The question is how can I make it run from 7:00 to 23:00 only? I don't want to use my computer resources at times where I'm sure my program won't be helpful...

https://stackoverflow.com/questions/65801396/python-how-to-freeze-program January 20, 2021 at 08:12AM

没有评论:

发表评论