import time tick = time.time() # 返回从12:00am, January 1, 1970(epoch) 开始的记录的当前操作系统时间 present = time.localtime() # 当前时间 format = time.asctime() # 格式化时间
time.clock() # 第一次调用,返回程序运行的实际时间
# 第二次之后的调用,返回自第一次调用后,到这次调用的时间间隔
# 在win32系统下,返回的是真实时间,而在Unix/Linux下返回的是CPU时间
import calendar calendar.month(2015, 5) # 日历显示
从1970年到现在,过去了多少年?
自定义格式化时间
time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
time.sleep(1) # 休眠1秒