# -*- coding: UTF-8 -*-
from datetime import datetime
# 开始时间
starttime = datetime.now()
#
import time
time.sleep(1)
# 结束时间
endtime = datetime.now()
time_span = endtime - starttime
print(type(time_span))
print(f'时间间隔:{time_span.days} 天')
print(f'时间间隔:{time_span.seconds} 秒')
'''
输出:
<class 'datetime.timedelta'>
时间间隔:0 天
时间间隔:1 秒
'''
'''
参考:
https://blog.youkuaiyun.com/Datapad/article/details/114930222
'''