outputting time in microseconds or milliseconds

Skip Montanaro skip at pobox.com
Fri Aug 2 11:15:53 EDT 2013


> is the third column is only the microsecond?

Yes.

> how could i get this to write with the rest of the time (the hh:mm:ss) ?

It sounds like you really want the time formatted in a particular way,
not just the numeric value of one or more fields.  Look at the
documentation for the strftime method of datetime objects for full
details:

http://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior

Here's a simple example:

>>> import datetime
>>> now = datetime.datetime.now()
>>> now.strftime("%H:%M:%S.%f")
'10:14:36.526110'

Skip



More information about the Python-list mailing list