什么是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