How to stop a program in python until a specific date and time

How to stop a program in python until a specific date and time

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

How to stop a program in python until a specific date and time
To represent date, time, time, and seconds in Python
How to get the date and time difference in seconds with python
Convert timezoned date and time to Unixtime in Python2.7
[Python] Rename all image files in a specific folder by shooting date and time
How to get a stacktrace in python
How to use is and == in Python
Determine the date and time format in Python and convert to Unixtime
How to start the PC at a fixed time every morning and execute the python program
How to clear tuples in a list (Python)
How to generate permutations in Python and C ++
How to embed a variable in a python string
How to get a specific column name and index name in pandas DataFrame
A clever way to time processing in Python
How to put a half-width space before letters and numbers in Python.
How to notify a Discord channel in Python
[Python] How to draw a histogram in Matplotlib
How to count numbers in a specific range
How to plot autocorrelation and partial autocorrelation in python
How to convert / restore a string with [] in python
How to measure processing time in Python or Java
[Python] How to expand variables in a character string
[Python] How to sort dict in list and instance in list
How to execute a command using subprocess in Python
How to develop in Python
How to generate a QR code and barcode in Python and read it normally or in real time with OpenCV
How to execute a schedule by specifying the Python time zone and execution frequency
[GCF + Python] How to upload Excel to GCS and create a new table in BigQuery
How to unit test a function containing the current time using freezegun in python
Script to count and stop up to 5 seconds in Python in Blender
How to slice a block multiple array from a multiple array in Python
How to swap elements in an array in Python, and how to reverse an array.
How to run a Python program from within a shell script
How to use the __call__ method in a Python class
[Python] Create a date and time list for a specified period
How to import a file anywhere you like in Python
[Introduction to Udemy Python 3 + Application] 36. How to use In and Not
How to generate exponential pulse time series data in python
How to define multiple variables in a python for statement
A standard way to develop and distribute packages in Python
How to develop in a virtual environment of Python [Memo]
Comparison of how to use higher-order functions in Python 2 and 3
How to get the last (last) value in a list in Python
How to get a list of built-in exceptions in python
Get the current date and time in Python, considering the time difference
How to write a metaclass that supports both python2 and python3
Just try to receive a webhook in ngrok and python
How to log in to AtCoder with Python and submit automatically
How to write a Python class
How to collect images in Python
How to use SQLite in Python
[Python] How to delete rows and columns in a table (list of drop method options)
Recursively get the Excel list in a specific folder with python and write it to Excel.
How to use Mysql in python
How to wrap C in Python
How to use ChemSpider in Python
How to use PubChem in Python
How to calculate date with python
How to handle Japanese in Python
When writing a program in Python
A Python program that collects tweets containing specific keywords daily and saves them in csv