0
点赞
收藏
分享

微信扫一扫

itchat

梦想家们 2022-05-19 阅读 30
# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""

import itchat, time
def lc():
print("Finash Login!")
def ec():
print("exit")

itchat.auto_login(loginCallback=lc, exitCallback=ec,hotReload=True)
friends=itchat.get_friends()
#print flist
male = female = other = 0
city={}
for i in friends[1:]:

c= i["City"]
if city.has_key(c) :
city[c]=city[c]+1
else:
city[c]=1

sex = i["Sex"]
if sex == 1:
male += 1
elif sex == 2:
female += 1
else:
other +=1
#计算朋友总数
total = len(friends[1:])

#打印出自己的好友性别比例
print("男性好友: %.2f%%" % (float(male)/total*100) + "\n" +
"女性好友: %.2f%%" % (float(female) / total * 100) + "\n" +
"不明性别好友: %.2f%%" % (float(other) / total * 100))

for (k,v) in city.items():
print k,v





举报

相关推荐

0 条评论