python 案例 009 (睡眠,时间format)

#!/usr/bin/python
# -*- coding:UTF-8 -*-
import  time
"""
pause for 2 seconds and format the timestamp

"""
def pause(n):
    for x in range(10):
        print x
        print  time.strftime('%Y/%m/%d %H:%M:%S', time.localtime(time.time()))
        time.sleep(n)
        print  time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))


pause(2)
'''
will cost some times to finish the loop
'''



posted @ 2017-07-18 22:35  yuerspring  阅读(177)  评论(0编辑  收藏  举报