微信机器人(实现自动回复,数据统计)

微信机器人的使用

安装:wxpy模块、pillow模块、pyecharts数据可视化模块(https://pyecharts.org # 官网)

用pkl模块保存的朋友数据,删除可以重扫 



from wxpy import * # 导入微信机器人模块所有
from pyecharts import Pie,Map # Pie是饼图,map是地图
import webbrowser

'''实例化微信机器人'''
bot = Bot(cache_path=True) # 参数True表示微信登陆后缓存好友信息

friends = bot.friends() # 拿到所有好友对象

'''生成饼图数据'''
attr = ['男性','女性','未知',]
value=[0,0,0]
for friend in friends:
if friend.sex == 1:
value[0] += 1
elif friend.sex == 2:
value[1] += 1
else:
value[2] += 1

pie = Pie('男女朋友比例') # 实例化对象
pie.add('',attr,value,is_label_show=True) # is_label_show=True 让效果好看点
pie.render('sex.html')
webbrowser.open('sex.html') # 让浏览器打开一个地址

猜你喜欢

转载自www.cnblogs.com/shizhengquan/p/10735148.html