查看time模块的所有函数

time()

以秒为单位将当前时间作为浮点型返回(1970.1.1至当前时间的秒数)

e.g:1566892931.970801

clock()

返回进程以浮点型启动后的CPU时间

e.g:5.688890507062189e-07

sleep()

以浮点型给出的延迟数秒

e.g:time.sleep(2):延迟2s

gmtime()

将epoch以来的秒数转换为UTC元组(epoch=1970.1.1)

e.g:time.struct_time(tm_year=2019, tm_mon=8, tm_mday=27, tm_hour=8, tm_min=10, tm_sec=26, tm_wday=1, tm_yday=239, tm_isdst=0)

localtime()

将epoch以来的秒数转换为本地时间元组

e.g:time.struct_time(tm_year=2019, tm_mon=8, tm_mday=27, tm_hour=16, tm_min=13, tm_sec=32, tm_wday=1, tm_yday=239, tm_isdst=0)

asctime()

将时间元组转换为字符串

e.g:'Tue Aug 27 16:14:16 2019'

ctime()

将时间(秒)转换为字符串

e.g:'Tue Aug 27 16:14:44 2019'

mktime() 将本地时间元组转换为自epoch(1970.1.1)以来的秒数
strftime()

根据格式规范将时间元组转换为字符串

e.g:

strptime() 根据格式规范将字符串解析为时间元组
tzset() 更改本地时区
原文地址:https://www.cnblogs.com/kite123/p/13755467.html