If you are creating multi-threaded programs in Python (and, let's face it, who isn't) you need a familiarity with the time module. The time module is always there, but some functions may only work on certain platforms.
time.time() - is the basic thing you need to know. It returns the number of seconds since the "epoch". The epoch is when time starts. On Jan 1 of that year at time 0, the "time since epoch" is zero. On Unix, and in chances are if you try this on Windows too, the epoch is 1970.
time.gmtime(0) - returns the epoch.
time.ctime(xx) - converts a time since the epoch into local time. This will show day, month year and time when printed.
time.sleep(s) - suspends execution for a given number of seconds.
time.time() - is the basic thing you need to know. It returns the number of seconds since the "epoch". The epoch is when time starts. On Jan 1 of that year at time 0, the "time since epoch" is zero. On Unix, and in chances are if you try this on Windows too, the epoch is 1970.
time.gmtime(0) - returns the epoch.
time.ctime(xx) - converts a time since the epoch into local time. This will show day, month year and time when printed.
time.sleep(s) - suspends execution for a given number of seconds.
No comments:
Post a Comment