# 时间截

# 1.计算时间截差

import time
import datetime
t1=time.time()
time.sleep(5)
t2=time.time()
print("相差",(datetime.datetime.fromtimestamp(t2)-datetime.datetime.fromtimestamp(t1)).seconds,"秒")
1
2
3
4
5
6