1.首先當然是下載python,下載python(建議下載3.6或者以上的版本)
2.打開cmd
python聊天機器人。3.輸入: pip install itchat ? ? ? 安裝itchat包
4.輸入python ? 進入python環境中
5.然后輸入以下代碼:
#coding=utf8
import requests
import itchatKEY = '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 defaultReplyitchat.auto_login(hotReload=True)
itchat.run()
6.掃二維碼登錄,等幾秒按回車出現Start auto replying.則完成
itcookers python?7.也是最重要的一點,若成功請點贊
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态