如题,编写了一个Python程序,目的为接入微信后收到信息然后返回相同的信息
代码:
#coding=utf-8
from wxpy import *
import itchat
from itchat.content import TEXT
@itchat.msg_register([TEXT])
def text_reply(msg):
return "收到消息:" + msg["Text"]
itchat.auto_login()
friends = itchat.get_friends()
groups = itchat.get_chatrooms()
itchat.send("hello world!01234",toUserName="filehelper")
thisuser=itchat.search_friends()["NickName"] #得到当前用户昵称
print(thisuser)
itchat.run(debug = True)
由于刚开始使用的时候未能成功,因此对itchat/components/login.py(按照网上的方法)插入了一个time.sleep(15)的语句。(应该不会影响这里)
最终程序在成功登入微信之后几秒钟会显示
Getting uuid of QR code.
Downloading QR code.
Please scan the QR code to log in.
Please press confirm on your phone.
Loading the contact, this may take a little while.
Login successfully as Poisonous Wine
Start auto replying.
xyzabc(这是本人的微信用户名)
No uins in 51 message
No uins in 51 message
Unexpected sync check result: window.synccheck={retcode:"1102",selector:"0"}
LOG OUT!
然后自动登出。
系统:Windows 11
在网上没有查到相关问题的有效解法,请教一下