模块:
itchat
功能:
获取个人的所有好友信息,需要扫描二维码
代码:
# 导入itchat模块
import itchat
def get_var():
vars = []
for i in friends:
value = i[var]
vars.append(value)
return vars
if __name__ == '__main__':
# 登陆
itchat.login()
# 获取好友信息,保持登陆状态
friends = itchat.get_friends(update=True)[0:]
# 昵称
name = get_var("NickName")
# 性别
sex = get_var("Sex")
# 省份
province = get_var("Province")
# 城市
city = get_var("City")
# 签名
signature = get_var("Signature")
all_value = zip(name, sex, province, city, signature)
male = 0
fmale = 0
for i in friends[1:]:
sex = i["Sex"]
if sex == 1:
male += 1
else:
fmale += 1
for value in all_value:
# 返回你的好友信息
print(value[0], value[1], value[2], value[3], value[4])
# 返回男女人数
print('男性:{0},女性:{1}'.format(male, fmale))