[Python] python中sleep函数用法演示 →→→→→进入此内容的聊天室

来自 , 2021-04-13, 写在 Python, 查看 136 次.
URL http://www.code666.cn/view/6a0724f1
  1. #------------------------------------------------------------------------------
  2. #           Name: sleep.py
  3. #         Author: Kevin Harris
  4. #  Last Modified: 02/13/04
  5. #    Description: This Python script demonstrates how to use the sleep()
  6. #                 function.
  7. #------------------------------------------------------------------------------
  8.  
  9. from time import sleep
  10.  
  11. print( "We'll start off by sleeping 5 seconds" )
  12.  
  13. sleep( 5 )
  14.  
  15. print( "Ok, time to wake up!" )
  16.  
  17. wait_time = int( input( "How much longer would you like to sleep? " ) )
  18.  
  19. while wait_time > 0:
  20.     print( "Ok, we'll sleep for " + str(wait_time) + " more seconds..." )
  21.     sleep( wait_time )
  22.     wait_time = int( input( "How much longer would you like to sleep? " ) )
  23.  
  24. print( "We're done!" )
  25.  
  26. #//python/8097

回复 "python中sleep函数用法演示"

这儿你可以回复上面这条便签

captcha