outputting time in microseconds or milliseconds
matt.doolittle33 at gmail.com
matt.doolittle33 at gmail.com
Fri Aug 2 11:09:15 EDT 2013
On Friday, August 2, 2013 8:35:13 AM UTC-4, Steven D'Aprano wrote:
> On Fri, 02 Aug 2013 03:54:32 -0700, matt.doolittle33 wrote:
>
>
>
> > Hey everybody,
>
> >
>
> > I am using 2.7 on Ubuntu 12.10. All I need to do is to print time with
>
> > the microseconds. I have been looking at the docs and trying things for
>
> > about half a day now with no success. Currently my code looks like
>
> > this:
>
> >
>
> > # write date and time and microseocnds
>
> > self.logfile.write('%s\t'%(str(strftime("%Y-%m-%d", ))))
>
> > self.logfile.write('%s\t'%(str(strftime("%H:%M:%S", ))))
>
> > self.logfile.write('%s\t'%(str(time())))
>
> What's this time() function? Where does it come from, and what does it
>
> do? By the look of it, it merely returns the string "00:00:00". The
>
> time.time() function returns a number of seconds:
>
> py> "%s" % time.time()
>
> '1375445812.873546'
>
>
right this is the number that i need in the third column. so should i try?:
> > self.logfile.write('%s\t'%(str(time.time())))
More information about the Python-list
mailing list