Python 函数----Time

我是python新手,先用博客记录我学习的过程吧,以后学得越多再逐步补全或纠正笔记.

首先看下dir下Time的参数(__XX__)不需要的,这里就不列出来了:

1 ['_STRUCT_TM_ITEMS','altzone', 'asctime', 'clock', 'ctime', 'daylight', 'get_clock_info', 'gmtime', 'localtime', 'mktime', 'monotonic', 'monotonic_ns', 'perf_counter', 'perf_counter_ns', 'process_time', 'process_time_ns', 'sleep', 'strftime', 'strptime', 'struct_time', 'thread_time', 'thread_time_ns', 'time', 'time_ns', 'timezone', 'tzname']

总共有下列参数和方法:

1. altzone:  返回UTC_GMT格林威治(英国天文台)所在地时间,偏移秒数,往东是负数.(>0,美洲;<=0大部分欧洲,亚洲,非洲)

    语法: time.altzone()   

 
 
import time

def procedure():
time.sleep(2.5)

#clock时间
t0=time.clock()
procedure()
print (time.clock() - t0, 'clock时间')

#time时间
t0=time.time()
procedure()
print (time.time() - t0, "time时间")

#time.process_time时间
t0=time.process_time()
procedure()
print (time.process_time() - t0, '程序运行时间,不包含睡眠时间')

#time.perf_counter时间
t0=time.perf_counter()
procedure()
print (time.perf_counter() - t0, '系统运行时间')
 
#返回结果
# 2.500562347 clock时间
#2.500372886657715 time时间
#0.0 程序运行时间
#2.4999300269999996 系统运行时间

3. 

猜你喜欢

转载自www.cnblogs.com/zzh-zjh/p/11223022.html