1time = 72.345
2
3hours = int(time)
4minutes = (time*60) % 60
5seconds = (time*3600) % 60
6
7print("%d:%02d.%02d" % (hours, minutes, seconds))
8>> 72:20:42
1>>> def frac(n):
2... i = int(n)
3... f = round((n - int(n)), 4)
4... return (i, f)
5...
6>>> frac(53.45)
7(53, 0.45) # A tuple
8
9>>> def frmt(hour): # You can rewrite it with 'while' if you wish
10... hours, _min = frac(hour)
11... minutes, _sec = frac(_min*60)
12... seconds, _msec = frac(_sec*60)
13... return "%s:%s:%s"%(hours, minutes, seconds)
14...
15>>> frmt(72.345)
16'72:20:42'
17>>> l = [72.345, 72.629, 71.327]
18>>> map(frmt, l)
19['72:20:42', '72:37:44', '71:19:37']
1str(int(math.floor(time))) + ':' + str(int((time%(math.floor(time)))*60)) + ':' + str(int(((time%(math.floor(time)))*60) % math.floor(((time%(math.floor(time)))*60))*60))