Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

leaving a time delay in python [duplicate]

Tags:

I would like to know how to put a time delay in a Python script.

like image 464
user46646 Avatar asked Feb 04 '09 07:02

user46646


People also ask

How do you delay 2 seconds in Python?

If you've got a Python program and you want to make it wait, you can use a simple function like this one: time. sleep(x) where x is the number of seconds that you want your program to wait.

Is there a delay command in Python?

Python time sleep function is used to add delay in the execution of a program. We can use python sleep function to halt the execution of the program for given time in seconds.


1 Answers

import time time.sleep(5)   # Delays for 5 seconds. You can also use a float value. 

Here is another example where something is run approximately once a minute:

import time while True:     print("This prints once a minute.")     time.sleep(60) # Delay for 1 minute (60 seconds). 
like image 98
Evan Fosmark Avatar answered Sep 27 '22 20:09

Evan Fosmark