python—微信

pip install itchat

注意这里的微信的扫码登陆时属于网页端登陆,如果是最近新注册的微信号就没有网页端登录了,我应该是14年左右注册的,是可以的

最好不要涉及太多群的操作,操作不能太频繁,否则网页端微信可能被封

 

登入

import itchat

itchat.auto_login()
#itchat.auto_login(hotReload=True)
itchat.send("Hello,filehelper", toUserName = 'filehelper')

itchat.auto_login(hotReload=True)  可以不用一次次的重复登录了就

 

发送回复给自己的文本消息

import itchat

@itchat.msg_register(itchat.content.TEXT)
def text_reply(msg):
    return msg['Text']

itchat.auto_login()
itchat.run()

@itchat.msg_register(itchat.content.TEXT)
itchat将根据接收到的消息类型寻找对应的已经注册的方法

 

reply_text=msg['Text']
设定一个reply_text储存我们的回复内容. msg[Text]是我们收到的文本消息内容,即默认回复收到的文本内容

 

根据微信文本内容回复消息

import itchat

@itchat.msg_register(itchat.content.TEXT)
def text_reply(msg):
    reply_text = msg['Text']
    if msg['Text'] == '你好':
        reply_text = '不好!'
    elif msg['Text'] == '你是谁':
        reply_text = "hxx!"
    return reply_text

itchat.auto_login()
itchat.run()

如果不是if else里面写的回复内容,就默认重复对方的话

 

 

 

 

 

 

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值