是否可以将 int 转换为 hours:min:sec
import datetime
x = 40000
t = int(x)
day = t//86400
hour = (t-(day*86400))//3600
min = (t - ((day*86400) + (hour*3600)))//60
seconds = t - ((day*86400) + (hour*3600) + (min*60))
hello= datetime.time(hour.hour, min.minute, seconds.second)
print (hello )
我想要这个输出:- 11:06:40
原文由 Rajas Rasam 发布,翻译遵循 CC BY-SA 4.0 许可协议
您还可以将所有除法和模运算外包给 Python 内置函数(记住: 电池是包含在内的!)