First install Itchat, you can see my other blog
Import Itchat
itchat.auto_login ()
itchat.send (' Hello, Filehelper ', tousername= ' Filehelper ')
This code means to send a hello,filehelper to Filehelper is the file assistant.
So we want to send a message to the designated person, not to get rid of filehelper so simple
Users=itchat.search_friends ("Lao Wang")
username= users[0][' userName ']
print (userName)
itchat.send (' Hello Old king ' , Tousername=username)
If we want to give old Kings news, we'll use the Itchat.search method first, and all the notes will be found by the old Wang's contact person.
Then we pick the first one (if you have only one old king in your contact list, you'll only find one).
USERS[0] Fetch is a contact object, he has a key called username, it is the real user's username
Then we use the Itchat.send method, we can successfully send the message to Lao Wang