need to print seconds from the epoch including the millisecond
roy at panix.com
Sat Dec 28 02:15:33 CET 2013
matt.doolittle33 at gmail.com wrote:
> I need to print the time in seconds from the epoch with
> millisecond precision.
> What happens if you do:
> t = time.time()
> self.logfile.write("str=%s, repr=%s", (str(t), repr(t)))
At the time I originally posted that, I was baffled as to what was going
on and was simply feeding you suggestions for how to go about debugging
the problem logically.
However, I have since figured out exactly what's going on. I'm going to
do you a favor and NOT tell you what I've figured out (because you won't
learn anything that way), but I will give you a hint. The hint is that
if you run the two lines of code I suggested above, the answer should be
And, once you do that, please report your findings back to us, because
it's a fun little quirk of Python and one that I suspect has tripped up
more than a few people over time. In fact, I seem to recall being
mystified by this myself once.
More information about the Python-list