我得到一个这样的start_date:
from django.utils.timezone import utc
import datetime
start_date = datetime.datetime.utcnow().replace(tzinfo=utc)
end_date = datetime.datetime.utcnow().replace(tzinfo=utc)
duration = end_date - start_date
我得到这样的输出:
datetime.timedelta(0, 5, 41038)
如何将此转换为正常时间,如下所示?
这样10分钟,1小时
我正在尝试增加时间并将输出设为hh:mm:ss,但是当日期时间超过24小时时,它就变成了x Days, hh:mm:ss.反正只有hh:mm:ss超过24小时吗?
import datetime
from datetime import timedelta
# intro
print("Welcome to TimeCalc")
print("Calculating Durations")
clear = True
while clear == True:
    # first input
    firstNumber = True
    while firstNumber == True:
        time_1 = input("Please enter a time [hh:mm:ss] including 0s: ")
        if len(time_1) > 0 and len(time_1) >= 8 and time_1[-6] == ":" and time_1[-3] == ":" and int(time_1[-5:-3]) < 60 and int(time_1[-2:]) < 60:
            hours_1 = time_1[:-6]
            minutes_1 = time_1[-5:-3]
            seconds_1 …