from datetime import datetime
import time
a = datetime.now() # 获得当前时间
time.sleep(2) # sleep 2s
b = datetime.now() # 获取当前时间
res = (b-a).seconds # 时间差,以秒显示
print(res )
start = time.time()
time.sleep(3)
end = time.time()
res = f'{end - start :.2f}'