Python Sleep休眠函数

转自: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秒

 

posted @ 2015-02-03 17:50  horizon~~~  阅读(84469)  评论(0编辑  收藏  举报