Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python time sleep() method

Python time sleep() method


Description

The Python time sleep() function delays the execution of the calling thread. The secs parameter specifies the number of seconds, indicating how long the process is suspended.

Syntax

sleep() method syntax:



time.sleep(t)

Parameters

Return Value

This function has no return value.

Example

The following example shows 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