outputting time in microseconds or milliseconds
Alain Ketterlin
alain at dpt-info.u-strasbg.fr
Sun Aug 4 07:57:08 EDT 2013
matt.doolittle33 at gmail.com writes:
> self.logfile.write('%s\t'%(str(time())))
[...]
> 2013-08-03 23:59:34 1375588774.89
[...]
> Why is it only giving me the centisecond precision? the docs say i
> should get microsecond precision with the code i put together.
Because of str()'s default format. Use "%f" % (time()) (and maybe vary
the precision).
-- Alain.
P/S: using str() + string formatting is kind of overkill: either use
string format directives like %f, or use str() with simple string
concatenation -- the latter giving less control.
More information about the Python-list
mailing list