首先确保你安装好了Python和Python的包管理工具pip
Welcome to Python.org
Installation - pip 9.0.1 documentation
之后只需要再安装两个python库
如果你对python感兴趣,我这有个学习Python基地,里面有很多学习资料,感兴趣的+Q群:688244617
pip install itchat pillow
然后再随便写这么几行代码
import itchat, time, re
from itchat.content import *
@itchat.msg_register([TEXT])
def text_reply(msg):
match = re.search('年', msg['Text']).span()
if match:
itchat.send(('那我就祝你鸡年大吉吧'), msg['FromUserName'])
@itchat.msg_register([PICTURE, RECORDING, VIDEO, SHARING])
def other_reply(msg):
itchat.send(('那我就祝你鸡年大吉吧'), msg['FromUserName'])
itchat.auto_login(enableCmdQR=True,hotReload=True)
itchat.run()
然后在命令行里运行
python index.py
用你自己的微信号扫描二维码(不是扫下面这个,是扫描你自己在命令行里生成的)
登录成功后会有如下提示
然后就大功告成啦(本示例在Win10+Python3.5.1环境下运行