Is there a way to schedule my script?

Chris Angelico rosuav at gmail.com
Wed Dec 17 16:34:33 EST 2014


On Thu, Dec 18, 2014 at 7:42 AM, Juan Christian
<juan0christian at gmail.com> wrote:
> Is there any kind of time calculation in Python that counts the time like 0,
> 1, 2, 3... so that 0AM would be 0, and 11:59PM would be let's say
> '645633332'? And everyday it gets a reset when the clock 'turns'?

time.time() % 86400

That's number of seconds since midnight UTC, ranging from 0 up to
86399. (I've no idea what 645633332 would mean. That's an awfully big
number for a single day.) If you offset that before calculating, you
can get that in your local time. Otherwise, just do the arithmetic
directly. Time isn't all _that_ hard to work with.

I don't see what's the big problem with just using sleep() though.
Isn't that exactly what you're after?

ChrisA



More information about the Python-list mailing list