Python time sleep() method


Description

Python time sleep() function delays the execution of the calling thread. The parameter secs indicates the number of seconds, representing the time the process is suspended.

Syntax

sleep() method syntax:

time.sleep(t)

Parameters

  • t -- the number of seconds to delay execution.

Return Value

This function has no return value.

Example

The following example demonstrates how to use the sleep() function:

Example

#!/usr/bin/python import time print "Start : %s" % time.ctime() time.sleep( 5 ) print "End : %s" % time.ctime()

The output of the above example is:

Start : Tue Feb 17 10:19:18 2013
End : Tue Feb 17 10:19:23 2013
Other Extensions