利用python微信库itchat实现微信自动回复功能,pythonitchat
利用python微信库itchat实现微信自动回复功能,pythonitchat
前言
在论坛上看到了用Python登录微信并实现自动签到,才了解到一个新的Python库: itchat
利用Python 微信库itchat,可以实现自动回复等多种功能,好玩到根本停不下来啊,尤其是调戏调戏不懂计算机的,特别有成就感,哈哈!!
代码如下:
#coding=utf8 import requests import itchat KEY = '8edce3ce905a4c1dbb965e6b35c3834d' def get_response(msg): apiUrl = 'http://www.tuling123.com/openapi/api' data = { 'key' : KEY, 'info' : msg, 'userid' : 'wechat-robot', } try: r = requests.post(apiUrl, data=data).json() return r.get('text') except: return @itchat.msg_register(itchat.content.TEXT) def tuling_reply(msg): defaultReply = 'I received: ' + msg['Text'] reply = get_response(msg['Text']) return reply or defaultReply itchat.auto_login(hotReload=True) itchat.run()
安装一下 itchat即可跑上面程序,实现与图灵机器人的交互。
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流,谢谢大家对帮客之家的支持。
相关内容
- python实现发送邮件及附件功能,python发送邮件
- python django 实现验证码的功能实例代码,pythondjango
- python分割列表(list)的方法示例,pythonlist
- python生成式的send()方法(详解),python生成式
- 浅谈Python生成器generator之next和send的运行流程(详解),
- Python实现SSH远程登陆,并执行命令的方法(分享),python
- Python实现Windows和Linux之间互相传输文件(文件夹)的方法
- Python对文件和目录进行操作的方法(file对象/os/os.path/s
- 通过源码分析Python中的切片赋值,
- 利用python写个下载teahour音频的小脚本,pythonteahour
评论关闭