python中time模块的用法

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年到现在,过去了多少年?

python中time模块的用法

自定义格式化时间

time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) 

time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())

python中time模块的用法

time.sleep(1) # 休眠1秒

上一篇:LInux下修改 ~/.bashrc 文件source ~/.bashrc 后 shell 命令 失效 任何命令都显示 “ bash XX :未找到命令”


下一篇:PHP与MYSQL结合操作——文章发布系统小项目(实现基本增删查改操作)