# How to return the current CPU time in Python?

PythonServer Side ProgrammingProgramming

To get the timer ticks at a given time, use the time.time() function. It returns the time in seconds since the epoch as a floating point number. Note that even though the time is always returned as a floating point number, not all systems provide time with a better precision than 1 second.

## Example

import time
curr_time = time.time()
print(curr_time)

## Output

1514823178.6920464

Note that different systems will have different accuracy based on their internal clock setup (ticks per second). but it's generally at least under 20ms. Also note while this function normally returns non-decreasing values, it can return a lower value than a previous call if the system clock has been set back between the two calls.

Updated on 19-Feb-2020 07:06:34

Advertisements