Python的itchat库,你的小助手

1.简单是几行代码,只需要安装itchat这个库,实现过程如下:
在这里插入图片描述
python第三方库itchat https://github.com/littlecodersh/ItChat

2.使用Python发送消息给你的朋友

import itchat
itchat.auto_login(hotReload=True)
print('扫描二维码')
remark_name = input('输入收信息人的备注:')
information = input('输入发送的内容:')
boom_ = itchat.search_friends(remarkName=remark_name)[0]['UserName']#指定人
for i in range(3):
    itchat.send_msg(information,toUserName=boom_)

3.使用Python给群发送消息

import itchat
itchat.auto_login(enableCmdQR=True)#另外一种载入二维码的方式
room_name = input('输入接收信息的群名:')
information = input('输入要发送的内容:')
#rooms=itchat.get_chatrooms(update=True) #拿到所有群
rooms_=itchat.search_chatrooms(name=room_name)[0]['UserName'] #指定群
for i in range(3):
    itchat.send(information,toUserName=rooms_)

4.使用Python给群发送消息+图片

print('扫一下二维码')
itchat.auto_login(enableCmdQR=True)
room_name = input('输入接收信息的群名称:')
rooms=itchat.get_chatrooms(update=True) #拿到所有群
rooms_=itchat.search_chatrooms(name=room_name)[0]['UserName'] #搜索指定群
itchat.send('第二节课的思维导图想要么?',toUserName=rooms_)
itchat.send("@img@%s" % 'mindmap.png',toUserName=rooms_)

@fil@path_to_file : 发送文件
@img@path_to_img : 发送图片
@vid@path_to_video : 发送视频

参考资料:

1.https://www.bilibili.com/read/cv11064085
2.https://blog.csdn.net/qq_41597912/article/details/82719217
3.https://zhuanlan.zhihu.com/p/33970981
4.https://zhuanlan.zhihu.com/p/64139965
5.https://itchat.readthedocs.io/zh/latest/

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值