Oct-16-2021, 02:20 AM
Greetings!
I'm trying to use 'functions in my code.
I want to add a timestamp for each different operation my code executes.
I made a function and I thought each time I'll call it I'll get a different timestamp.
For some reason, it prints the same timestamp.
I'm trying to use 'functions in my code.
I want to add a timestamp for each different operation my code executes.
I made a function and I thought each time I'll call it I'll get a different timestamp.
For some reason, it prints the same timestamp.
import time
def get_time():
import time
t_now = time.strftime("%Y-%m-%d %H:%M:%S")
t_now=str(t_now)
return t_now
print(t_now)
tst = get_time()
print (tst)
time.sleep(5)
print (tst)Thank you for your help!
