need to print seconds from the epoch including the millisecond

Chris Angelico rosuav at gmail.com
Fri Jan 3 10:41:11 EST 2014


On Sat, Jan 4, 2014 at 2:33 AM, Grant Edwards <invalid at invalid.invalid> wrote:
> time.time() returns a Python float. A Python float will have 16 digits
> of precision. Perhaps the OS always sets some of those digits to 0 (or
> even random values), but they're still there.  Perhaps the accuracy or
> granularity of the values returned is problematic on some OSes, but
> the precision of the value doesn't change: there's no way he's "only
> getting 2 decimal places" from time.time() unless (as you mention
> below) he's printing them using a method that truncates/rounds.

If I print out the value float("1.01"), I get just three digits. When
those trailing digits are all zeroes, they won't be displayed. That's
exactly what the OP was seeing.

ChrisA



More information about the Python-list mailing list