hours, milliseconds = divmod(miliseconds, 3600000)
minutes, milliseconds = divmod(miliseconds, 60000)
seconds = float(milliseconds) / 1000
s = '%i:%02i:%06.3f' % (hours, minutes, seconds)
How to convert time format into milliseconds and back in Python?