发布时间:2019-08-26 07:21:34编辑:auto阅读(2163)
计算两个时间点之间的时间间隔,可使用以下方法:
参考 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
51364
50837
41424
38224
32719
29613
28433
23338
23280
21609
1698°
2423°
2026°
1964°
2301°
1990°
2700°
4515°
4341°
3094°