Home  >  Q&A  >  body text

How does itchat.send of python's itchat WeChat api document send information to a specified user?

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

Cannot send messages to myself

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

You can’t send it to others either (User is a WeChat account )

为情所困为情所困2685 days ago1777

reply all(1)I'll reply

  • 仅有的幸福

    仅有的幸福2017-06-12 09:27:00

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

    Or send directly with this user

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

    reply
    0
  • Cancelreply