Since I started IT, many operations took a long time. For example, it took 40 minutes to compile and install TensorFlow last time, and it took 20 minutes for pyinstaller to package it once. So I thought of establishing a prompt mechanism, and after the operation is completed, a message is sent to the mobile phone to prompt the completion.
A python API of WeChat is used here: itchat package.
pip install itchat:
pip install -i https://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com itchat
Write the main program (cmdWeChat.py):
import itchat import sys if __name__ == '__main__': itchat.auto_login(hotReload=True) if len(sys.argv)<3: exit(0) objName=sys.argv[1] msg=sys.argv[2] users = itchat.search_friends(name=objName) #找到UserName if len(users)>0: userName = users[0]['UserName'] itchat.send(msg,toUserName = userName) #Then send him a message print( ' Object: ' +objName+ ' , message: ' + msg) else : print( ' Send object search failed ' )
Write a shorthand command script (note.cmd):
python F:\diyTools\cmdWeChat.py *** The program is finished
Put note.cmd in F:\diyTools\, add F:\diyTools\ to the environment variable
All right. Run in console:
Then you can get the message on the phone:
A little more troublesome is to set up a WeChat trumpet...