如何在python每天的特定时间运行一个函数?

How to run a function every day at a specific time in python?

所以,这就是我一直在尝试做的事情。 我正在制作一个小程序,可以准时发送到我的 类,这样我就不会错过它们。 我在最重要的部分有问题……自动化! 这是我的代码:

from pyautogui import *
import pyautogui
import keyboard
from pynput.keyboard import Key, Controller
import webbrowser

pos = pyautogui.position()
print(pos)

def open_b():
    pyautogui.click(248, 754)
    url='https://myclass.com'
    webbrowser.open_new_tab(url)```

一个简单的解决方案是:

import time
import datetime

# Enter the first class date and time
class_time = datetime.datetime(year, month, day, hour=13, minute=30, second=0)

delta = datetime.timedelta(days=1)
while True:
    
    if datetime.datetime.now() >= class_time:
        your_function()
        class_time += delta

    # Depending on need, check frequency can be decreased
    time.sleep(1)