I want to know how to put delay in a Python script.
import time
time.sleep(5) # delays for 5 seconds
Here is another example where something is run once a minute:
import time
while True:
print "This prints once a minute."
time.sleep(60) # Delay for 1 minute (60 seconds)
Please read http://www.faqts.com/knowledge_base/view.phtml/aid/2609/fid/378, which can help you further:
Try the sleep function in the time module.
import time time.sleep(60)
And put this in a while loop and a statement will only execute on the minute... That allows you to run a statement at predefined intervals regardless of how long the command takes (as long as it takes less than a minute or 5 or 60 or whatever you set it to) For example, I wanted to run a ping once a minute. If I just time.sleep(60) or time.sleep(45) even, the ping will not always take the same amount of time. Here's the code :)
time.sleep(time.localtime(time.time())[5])
The [5] just pulls the seconds out of the time.localtime()'s return value.
The great thing about time.sleep is that it supports floating point numbers!
import time time.sleep(0.1)