python抓取微信通讯录信息

关键词:Bot chats() friends() groups() mps()
库:wxpy

code Part_1:
from wxpy import *
bot = Bot() #初始化
my_friends = bot.friends() #获取好友
print(type(my_friends))

code Part_2: 统计性别
关键词:sex_dict
sex_dict = {‘male’:0,‘female’:0}
for friend in my_friends:
if friend.sex == 1:
sex_dict[‘male’] += 1
elif friend.sex == 2:
sex.dict[‘female’] += 1
print(sex_dict)

你可能感兴趣的:(玩起来)