import datetime,time
start_tm=datetime.datetime.now()
time.sleep()
end_tm=datetime.datetime.now()
print((end_tm-start_tm).seconds)
输出
2023-10-11 22:32:28
import datetime,time
start_tm=datetime.datetime.now()
time.sleep()
end_tm=datetime.datetime.now()
print((end_tm-start_tm).seconds)
输出