Ask coding questions

← Back to all posts
Python clock?
112596

Is there a way that I can give my Python code a sense of time, so that I can run code snippets based on the time of day? Perhaps with a module of some sort?

Answered by CodeMaster007 [earned 5 cycles]
View Answer
Voters
112596
Comments
hotnewtop
CodeMaster007

https://data-flair.training/blogs/alarm-clock-python/

Did you check out this? Basically it imports the needed packages, created a while loop (which is like the backend of the project), and just uses a simple GUI to display the time and show the user the time and set a alarm. Hope this is what you are looking for!

IMayBeMe

You could have a main script which runs other files as different times of day. That’s the best way to do it as far as I’m concerned.

112596

@IMayBeMe how would the code know what time of day it is?

IMayBeMe

@112596 use the time module, it gets the time from a certain time zone