zoukankan      html  css  js  c++  java
  • itchat

    # -*- 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) + "
    " +
    "女性好友: %.2f%%" % (float(female) / total * 100) + "
    " +
    "不明性别好友: %.2f%%" % (float(other) / total * 100))
    
    for (k,v) in city.items():
        print k,v
    

      

  • 相关阅读:
    Zepto源码分析-动画(fx fx_method)模块
    CSS3用法理解
    移动端网页meta设置和响应式
    javascript基础-正则表达式
    net core 2.x
    angular
    .net core 2.x
    .net core 2.x
    DDD
    DDD
  • 原文地址:https://www.cnblogs.com/ahuo/p/10208934.html
Copyright © 2011-2022 走看看