import time
print time.time() - time.time()
结果单元是millisecond
还是second
?
我想做的是判断两个操作时间跨度是否大于10分钟
答案 0 :(得分:5)
返回自纪元以来的秒数作为浮点数。 (来自documentation)
因此,两次之间的差异也是秒。
time_a = time.time()
# ... some operations ...
ten_minutes = 10 * 60
time_span = time.time() - time_a
if time_span > ten_minutes:
# time span is larger than 10 minutes.