how to time in python code example
Example 1: python time a funciton
import time
start = time.time()
print("hello")
end = time.time()
print(end - start)
Example 2: python how to measure code run in time
import time
start_time = time.time()
main()
print("--- %s seconds ---" % (time.time() - start_time))
Example 3: python time seconds
import time
seconds = 1545925769.9618232
local_time = time.ctime(seconds)
print("Local time:", local_time)
Example 4: time python
import time
dir(time)
[..., 'localtime', 'mktime', 'sleep', 'sleep_ms', 'sleep_us', 'ticks_add', 'ticks_cpu', 'ticks_diff', 'ticks_ms', 'ticks_us', 'time']
secFromStart = time.time()
Example 5: time in python code
import datetime
x = datetime.datetime.now()
print(x)