pip install wxpy
微信好友男女比例
from wxpy import *
from pyecharts import Pie
import webbrowser
bot = Bot(cache_path=True) # 登录微信
friend = bot.friends().search(“盼”)[0]
friend.send(‘lalala’)
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(“lalal”)
pie.add("", attr, value, is_label_show=True)
pie.render(“friend.html”)
webbrowser.open(“friend.html”)