Advertisement
python_notes

Sleep Function

Jul 31st, 2014
482
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. #Python Sleep function
  2.  
  3.  
  4. #Example 1
  5.  
  6.  
  7. time.sleep(5)         # sleeps for 5 seconds
  8.  
  9.  
  10. #Example 2
  11.  
  12.  
  13. time.sleep(0.5)      #sleeps for a half second
  14.  
  15.  
  16.  
  17. #Example 3
  18.  
  19. from time import sleep
  20.  sleep(Num of seconds to sleep)
  21.  
  22.  
  23.  
  24. #Example 4
  25.  
  26. import time
  27. while True:
  28.     print "This prints once a minute."
  29.     time.sleep(60)  # Delay for 1 minute (60 seconds)
  30.  
  31.  
  32.  
  33.  
  34. #Example 5
  35.  
  36.  import time
  37.  time.sleep(Num of seconds to sleep)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement