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
'''



原文地址:https://www.cnblogs.com/TendToBigData/p/10501223.html