python

您所在的位置:网站首页 python安装itchat库 python

python

2023-09-13 13:42| 来源: 网络整理| 查看: 265

什么是API?

API:(Application Programming Interface,应用程序编程接口)是一些预先定义的函数,目的是提供应用程序与开发人员基于某软件或硬件得以访问一组例程的能力,而又无需访问源码,或理解内部工作机制的细节

1.利用itchat模块给手机助手发信息及文件

import itchat import time hotReload = True ##保留登录登录状态,段时间内不会自动登录 itchat.auto_login() while True: itchat.send('hello',toUserName='filehelper') ##对手机助手发送消息 # itchat.send_file('/etc/passwd', toUserName='filehelper') ##对手机助手发送文件 time.sleep(3) ##每3秒发送一次

执行命令,出现二维码,扫码登录,微信文件助手会出现发送来的短信及文件

Getting uuid of QR code. Downloading QR code. Please scan the QR code to log in. Please press confirm on your phone. Loading the contact, this may take a little while. Login successfully as 『被活捉的萌懒猫』 ##登录成功

2.统计微信里的男女好友比例

import itchat import time hotReload = True itchat.auto_login() friends = itchat.get_friends() ##获取好友列表 print(friends) info = {} for friend in friends[1:]: if friend['Sex'] == 1: info['male'] = info.get('male',0)+1 elif friend['Sex'] == 2: info['female'] = info.get('female',0)+1 else: info['other'] = info.get('other',0)+1 print(info)

结果输出

[


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3