1. 使用`itchat`库
import itchat登录微信itchat.auto_login()搜索要发送信息的好友或群聊friend = itchat.search_friends(name='好友的昵称')获取好友的UserNamefriend_username = friend['UserName']发送信息itchat.send('你要发送的信息', toUserName=friend_username)运行程序itchat.run()

2. 使用`pyautogui`和`pyperclip`库
import pyautoguiimport pyperclipimport time提前打开微信,等待一段时间time.sleep(10)需要发送的内容message = '早起的鸟儿有霾吸'复制内容到剪贴板pyperclip.copy(message)模拟鼠标点击发送按钮pyautogui.hotkey('ctrl', 'v') 按下 Ctrl+Vpyautogui.mouseUp() 模拟鼠标将左键抬起设置等待时间time.sleep(30)
请注意,使用这些方法自动发送信息可能违反微信的使用条款,并可能导致账号被封禁。请确保你有合法的理由和权限使用这些技术。
