Computer >> Computer tutorials >  >> Programming >> Python

How can I make a time delay in Python?


In order to introduce delay of definite interval, we can use sleep() function that is available in time module of Standard Python library. The sleep() function takes an integer number corresponding to seconds as an argument.

time.sleep(sec)

Example

In following example, current time is first displayed and then the execution is paused for 10 seconds using sleep() function.

import time
print ("current time : ",time.ctime())
time.sleep(10)
 print ("after 10 sec : ",time.ctime())