from time import time time_in_seconds = int(time()) time_in_miliseconds = int(time_in_seconds *1000)
You can also use str (x) to convert x to string. From there, you can use various methods to create the desired line, for example: (both of them assume that you already have the hrs, min, sec, msec variables with the values โโyou want)
str(hrs) + ':' + str(min) + ':' + str(sec) + '.' + str(msec)
or, more pythonically:
'{hrs}:{min}:{sec}.{msec}'.format(hrs = str(hrs), min = str(min), sec = str(sec), msec = str(msec))
Alternatively, you can use the strftime () function in the time module if you want to use the current time. check out http://docs.python.org/library/time.html
source share