📜  python 在特定的日期时间运行东西 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:51.344000             🧑  作者: Mango

代码示例1
import datetime as DT
import time

while True:
    now = DT.datetime.now()
    target = DT.datetime.combine(DT.date.today(), DT.time(hour=8))
    if target < now:
        target += DT.timedelta(days=1)

    time.sleep((target-now).total_seconds())
    # do something