I am trying to make the timedelta to display time in H:M:S:MS
format , i am able to display in H:M:S
format using datetime.timedelta
function like below
print((datetime.timedelta(minutes=500)))
output: 8:20:00
How can i get the output as 8:20:00:00
in H:M:S:MS
You can add one:
print(str(datetime.timedelta(minutes=500))+':0')
Output:
8:20:00:0
One way to go is using string formating:
d = datetime.timedelta(minutes=500)
print('%s:%s' % (str(d), d.microseconds))
# 8:20:00:0
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.