This article mainly introduces the usage of sleep functions in python. The example analyzes the functions and usage skills of sleep functions, which is very useful, for more information about the sleep function usage in python, see the following example. Share it with you for your reference. The details are as follows:
Sleep in Python is used to pause thread execution, in seconds
# ----------------------------------- # Name: sleep. py # Author: Kevin Harris # Last Modified: 02/13/04 # Description: This Python script demonstrates # how to use the sleep () # function. # --------------------------------- from time import sleepprint ("We'll start off by sleeping 5 seconds") sleep (5) print ("OK, time to wake up! ") Wait_time = int (input (" How much longer wocould you like to sleep? ") While wait_time> 0: print (" OK, we'll sleep for "+ str (wait_time) +" more seconds... ") sleep (wait_time) wait_time = int (input (" How much longer wowould you like to sleep? ") Print (" We're done! ")
I hope this article will help you with Python programming.