For example, how to stop the program until Halloween 2020 and restart it when Halloween comes.
import datetime
import time
HALLOWEEN2020 = datetime.datetime(2020, 10, 31, 0, 0, 0)
while datetime.datetime.now() < HALLOWEEN2020:
time.sleep(1)
print('It's halloween!')
By using time.sleep, I try to check the time every second. It's enough to check every second, so you don't waste your cpu. .. .. It seems to mean that.
** See: "Let Python do the boring things-automated programming that non-programmers can do" **
Recommended Posts