import itchat
import time
itchat.auto_login(hotReload=True)
group_username = '群聊的UserName'
def send_message():
message = "要发送的消息"
itchat.send(message, toUserName=group_username)
def schedule_task():
while True:
# 获取当前时间
current_time = time.strftime('%H:%M', time.localtime())
# 设置发送时间,例如每天的10:30发送消息
if current_time == '10:30':
send_message()
# 休眠一段时间,避免频繁检查时间
time.sleep(60)
schedule_task()
参考GPT和自己的思路:这份代码可能存在SyntaxError语法错误或IndentationError缩进错误,无法直接确定报错具体位置。可以尝试使用Python的IDE或者命令行执行代码,看看抛出的具体异常信息有哪些,并根据异常信息来查找问题所在位置和原因。
报什么错?