[英]How transform days to hours, minutes and seconds in Python
I have value 1 day, 14:44:00
which I would like transform into this: 38:44:00
.我有价值
1 day, 14:44:00
我想转换成这个: 38:44:00
。
I've tried the following code:我试过以下代码:
myTime = ((myTime.days*24+myTime.hours), myTime.minutes, myTime.seconds)
But it doesn't work.但它不起作用。 I got this error message:
我收到此错误消息:
'datetime.timedelta' object has no attribute 'hours'
'datetime.timedelta' 对象没有属性 'hours'
The timedelta object doesn't have hours property. timedelta 对象没有 hours 属性。 Only
microseconds
, seconds
and days
.只有
microseconds
、 seconds
和days
。
Use:用:
myTime = '%02d:%02d:%02d.%06d' % (myTime.days*24 + myTime.seconds // 3600, (myTime.seconds % 3600) // 60, myTime.seconds % 60, myTime.microseconds)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.