转自:http://www.cnblogs.com/jamespb/archive/2011/10/11/2207513.html

Python 编程中使用 time 模块可以让程序休眠,具体方法是time.sleep(秒数),其中"秒数"以秒为单位,可以是小数,0.1秒则代表休眠100毫秒。 

# -*- coding: utf-8 -*-

import time
import sys

# 解决中文转码
reload(sys)
sys.setdefaultencoding( "utf-8" )

# 循环输出休眠1秒
i = 1
while i <= 3:
    print i # 输出i
    i += 1
    time.sleep(1) # 休眠1秒

 

相关文章:

  • 2021-08-14
  • 2022-12-23
  • 2022-12-23
  • 2023-03-20
  • 2022-12-23
  • 2022-02-12
猜你喜欢
  • 2021-07-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
  • 2022-12-23
相关资源
相似解决方案