pip install itchat
注意这里的微信的扫码登陆时属于网页端登陆,如果是最近新注册的微信号就没有网页端登录了,我应该是14年左右注册的,是可以的
最好不要涉及太多群的操作,操作不能太频繁,否则网页端微信可能被封
登入
import itchat itchat.auto_login() #itchat.auto_login(hotReload=True) itchat.send("Hello,filehelper", toUserName = 'filehelper')
itchat.auto_login(hotReload=True) 可以不用一次次的重复登录了就
发送回复给自己的文本消息
import itchat @itchat.msg_register(itchat.content.TEXT) def text_reply(msg): return msg['Text'] itchat.auto_login() itchat.run()
@itchat.msg_register(itchat.content.TEXT)
itchat将根据接收到的消息类型寻找对应的已经注册的方法reply_text=msg['Text']
设定一个reply_text储存我们的回复内容. msg[Text]是我们收到的文本消息内容,即默认回复收到的文本内容根据微信文本内容回复消息
import itchat @itchat.msg_register(itchat.content.TEXT) def text_reply(msg): reply_text = msg['Text'] if msg['Text'] == '你好': reply_text = '不好!' elif msg['Text'] == '你是谁': reply_text = "hxx!" return reply_text itchat.auto_login() itchat.run()
如果不是if else里面写的回复内容,就默认重复对方的话
python—微信
猜你喜欢
转载自blog.csdn.net/hxxjxw/article/details/104849938
今日推荐
周排行