发布时间:2019-08-26 07:21:34编辑:auto阅读(1939)
计算两个时间点之间的时间间隔,可使用以下方法:
参考 https://docs.python.org/3/library/datetime.html#module-datetime
import datetime
starttime = datetime.datetime.now()
#long running
endtime = datetime.datetime.now()
duringtime = endtime - starttime
print duringtime.seconds
两者相减,得到的duringtime
是一个timedelta
的实例,这个实例自身有属性有
days
seconds
microseconds
import time
a = time.time()
# short running
b = time.time()
seconds = b - a
m, s = divmod(seconds, 60)
h, m = divmod(m, 60)
print ("%02d:%02d:%02d" % (h, m, s))
参考:
https://www.jianshu.com/p/03d6e9867fdf
https://blog.csdn.net/xiaoQL520/article/details/78435175
上一篇: python使用dom操作xml
下一篇: Python 3.x基于Xml数据的Ht
48944
48073
38818
35940
30358
27144
26141
20977
20802
19152
691°
761°
739°
743°
721°
676°
785°
860°
998°
1246°