The standard time.time()
function provides sub-second precision, though that precision varies by platform. For Linux and Mac precision is +-
1 microsecond or 0.001 milliseconds. Python on Windows uses +-
16 milliseconds precision due to clock implementation problems due to process interrupts. The timeit
module can provide higher resolution if you're measuring execution time.
>>> import time
>>> time.time() #return seconds from epoch
1261367718.971009
Python 3.7 introduces new functions to the time
module that provide higher resolution:
>>> import time
>>> time.time_ns()
1530228533161016309
>>> time.time_ns() / (10 ** 9) # convert to floating-point seconds
1530228544.0792289
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…