2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > python登录微信自动发送消息和绘画好友男女比例

python登录微信自动发送消息和绘画好友男女比例

时间:2024-03-17 17:14:08

相关推荐

python登录微信自动发送消息和绘画好友男女比例

#coding=utf-8

import sys

reload(sys)

sys.setdefaultencoding( "utf-8" )

import itchat

# itchat.login()

# itchat.send(u"您好",'filehelper')

#这样你就可以保持一段时间登录状态,而不用每次运行代码都要扫码登录了!

itchat.auto_login(hotReload=True)

itchat.dump_login_status()

itchat.send(u"您好",'filehelper') #给自己的文件传输助手发送消息

friends=itchat.get_friends(update=True)[:]

total=len(friends)-1

male=female=other=0

for friend in friends[1:]:

sex=friend["Sex"]

if sex==1:

male+=1

elif sex==2:

female+=1

else:

other+=1

from echarts import Echart,Legend,Pie

chart=Echart("%s的微信好友性别比例" %(friends[0])['NickName'],'from Wechat')

chart.use(Pie('WeChat',

[{'value': male, 'name': '男性 %.2f%%' % (float(male) / total * 100)},

{'value': female, 'name': '女性 %.2f%%' % (float(female) / total * 100)},

{'value': other, 'name': '其他 %.2f%%' % (float(other) / total * 100)}],

radius=["50%", "70%"]))

chart.use(Legend(["male", "female", "other"]))

del chart.json["xAxis"]

del chart.json["yAxis"]

chart.plot()

--------

运行后会自动弹出微信登录二维码,扫码后登陆微信成功

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。