微信调用itchat库 实现发消息

import itchat,timefrom itchat.content import *itchat.auto_login(enableCmdQR=-1)while True:    for i in range(1,10):        if i == 3:            friend_cijingchangcun = itchat.search_friends("此景长存")    #获取我的字典信息            jiangxinlong=friend_cijingchangcun[0]["UserName"]           #筛选我的信息            friend_danding = itchat.search_friends("淡定")            wangdong = friend_danding[0]["UserName"]            print(jiangxinlong)            friend_list=[wangdong,jiangxinlong]            content=i #发送的消息            for i in friend_list:                itchat.send_msg(msg=content,toUserName=i)  #发送信息给微信好友            time.sleep(5)        elif i == 7:            friend_cijingchangcun = itchat.search_friends("此景长存")  # 获取我的字典信息            jiangxinlong = friend_cijingchangcun[0]["UserName"]  # 筛选我的信息            friend_danding = itchat.search_friends("淡定")            wangdong = friend_danding[0]["UserName"]            print(jiangxinlong)            friend_list = [wangdong, jiangxinlong]            content = i  # 发送的消息            for i in friend_list:                itchat.send_msg(msg=content, toUserName=i)  # 发送信息给微信好友            time.sleep(5)        else:            time.sleep(5)
相关文章
相关标签/搜索