@spiritnotes
2016-07-23T16:17:14.000000Z
字数 437
阅读 1462
Python
DOING
time模块提供了一些用于管理时间和日期的c库函数。
返回纪元开始的秒数,为浮点数,具体精度和平台有关。
import time
time.time()
用于返回打印时间
time.ctime()
#'Sun Jul 24 00:09:24 2015'
返回处理器时间,一般用于性能测试和基准测试。
time.clock()
0.798551
用于获取struct_time格式,可以采用各个属性值进行访问,如s.tm_year ...
前者用于将字符串格式转换为struct_time格式。
后者将时间格式化为字符串。
用于将struct_time转换为时间的浮点数表示
用于将当前线程交出,等待相应时间后再唤醒。
def f():
while True:
time.sleep(5)
do_sonmething()