Pythonが微信に登る男女の人数と各地区の人数
660 ワード
wxpyモジュールをインポートする必要があります
from wxpy import *
bot = Bot(cache_path=True) #
friends_stat = bot.friends().stats()
friend_loc = [] # ,
for province, count in friends_stat["province"].items():
if province != "":
friend_loc.append([province, count])
#
friend_loc.sort(key=lambda x: x[1], reverse=True)
# 10
for item in friend_loc[:10]:
print(item[0], item[1])
for sex, count in friends_stat["sex"].items():
# 1 , 2
if sex == 1:
print(" : %d" % count)
elif sex == 2:
print(" : %d" % count)