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.
Thank you for your help!
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
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) |