outputting time in microseconds or milliseconds

matt.doolittle33 at gmail.com matt.doolittle33 at gmail.com
Sun Aug 4 07:30:08 EDT 2013


ok so now i import the module like this:

   from time import strftime, time

i made the write statement like this:

   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())))

(oh and btw,i know the code is hacker ugly).  
and the output is this:

2013-08-03	23:59:34	1375588774.89
2013-08-03	23:59:35	1375588775.06
2013-08-03	23:59:35	1375588775.25
2013-08-03	23:59:35	1375588775.43
2013-08-03	23:59:35	1375588775.80
2013-08-03	23:59:35	1375588775.99
2013-08-03	23:59:35	1375588775.99
2013-08-03	23:59:35	1375588775.99
2013-08-03	23:59:35	1375588776.00
2013-08-03	23:59:36	1375588776.15
2013-08-03	23:59:36	1375588776.15
2013-08-03	23:59:36	1375588776.16
2013-08-03	23:59:36	1375588776.16
2013-08-03	23:59:36	1375588776.16
2013-08-03	23:59:36	1375588776.16
2013-08-03	23:59:36	1375588776.16
2013-08-03	23:59:36	1375588776.16
2013-08-03	23:59:36	1375588776.16
2013-08-03	23:59:36	1375588776.34
2013-08-03	23:59:36	1375588776.35
2013-08-03	23:59:36	1375588776.35
2013-08-03	23:59:36	1375588776.35

the first two columns are for eyes so if they are a microsecond apart it doesn't matter. the numbers in the third column are for calculating duration which is where i need the precision. 

Why is it only giving me the centisecond precision?  the docs say i should get microsecond precision with the code i put together.

Thanks!



More information about the Python-list mailing list