Python time 的应用
-
测试如下:
import time
print("chenfulin")
# 返回格林威治西部的夏令时区
print("time.altzone %d" % time.altzone
# 获取时间,打印时间
t = time.localtime()
print(t)
print("time.asctime(t) : %s" % time.asctime(t))
# 延时
def my_sleep():
time.sleep(3)
# 计算sleep函数调用的时间时间
t0 = time.clock()
my_sleep()
t1 = time.clock()
print("function clock time : %d" % (t1 - t0))
t0 = time.time()
my_sleep()
t1 = time.time()
print("sleep time %d" % (t1 - t0))
# 打印字符时间
print("time.ctime() : %s" % time.ctime())
-
结果如下:
Read The Fucking Source Code