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()
?
?
?
--------
運行后會自動彈出微信登錄二維碼,掃碼后登陸微信成功
轉載于:https://www.cnblogs.com/mias/p/7238138.html
總結
以上是生活随笔為你收集整理的python登录微信自动发送消息和绘画好友男女比例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MaxCompute的任务状态和多任务执
- 下一篇: websocket python爬虫_p