python 时间模块学习

import time

print time.time()       #返回纪元开始的秒数
print time.ctime()      # 正常的打印时间
print time.clock()      #clock()返回处理器时钟时间,它的返回值一般用于性能测试与基准测试。因此它们反映了程序的实际运行时间。

from time import gmtime,strftime
print strftime("%a, %d %b %Y %H:%M:%S ", gmtime())
#Mon, 11 Jul 2016 14:25:11
print strftime("%a, %d %b %Y %H:%M:%S ")


'''
def fucn():
    time.sleep(5)
    print "hello, world"
fucn()
#sleep函数用于将当前线程交出,要求它等待系统将其再次唤醒,如果写程序只有一个线程,这实际上就会阻塞进程,什么也不做
'''
原文地址:https://www.cnblogs.com/aallenn/p/6700626.html