您的位置:首页技术文章
文章详情页

python的 itchat微信api文档的 itchat.send如何发信息给指定用户?

【字号: 日期:2022-06-29 11:06:53浏览:64作者:猪猪

问题描述

itchat.send_msg(’Hello world’)<ItchatReturnValue: {u’MsgID’: u’’, u’LocalID’: u’’, u’BaseResponse’: {u’ErrMsg’: u’’, u’Ret’: 1204, ’RawMsg’: u’’}}>

不能发给自己信息

itchat.send(’hello’,toUserName = User)

发给别人也不行( User 是一个微信号

问题解答

回答1:

#想给谁发信息,先查找到这个朋友users = itchat.search_friends(name=u’通讯录备注名’)#找到UserNameuserName = users[0][’UserName’]#然后给他发消息itchat.send(’hello’,toUserName = userName)

或者每直接用这个用户发送

user = itchat.search_friends(name=u’通讯录备注名’)[0]user.send(u’机器人say hello’)

标签: 微信 Python
相关文章: