SHARE
TWEET

loop_datetime_example

DeaD_EyE May 20th, 2018 122 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import datetime
  2.  
  3. time_target = datetime.datetime(2018, 5, 20, 13, 0)
  4.  
  5. while True:
  6.     time_now = datetime.datetime.now()
  7.     if time_now > time_target:
  8.         print('Doing something')
  9.         break
  10.     time.sleep(5) # wait 5 seconds
  11.  
  12. # program ends, when time_target has been reached.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top