zoukankan      html  css  js  c++  java
  • 【statistics】查看2018.4.25日理想论坛某ID在一天中的活跃情况

    用于统计的sum.py代码:

    import re
    import pymysql
    
    # 入口函数
    def main():
        dic={'00':0,'01':0,'02':0,'03':0,'04':0,'05':0,'06':0,'07':0,'08':0,'09':0,'10':0,'11':0,'12':0,'13':0,'14':0,'15':0,'16':0,'17':0,'18':0,'19':0,'20':0,'21':0,'22':0,'23':0}
    
        conn=pymysql.connect(host='127.0.0.1',user='root',passwd='12345678',db='test',charset='utf8')
    
        cs=conn.cursor()
        cs.execute("select * from topic0426 where author='天山剑阁' and tdate='2018-4-25'")
        results = cs.fetchall()
    
        for row in results:
            ttime=row[4]
            hour=ttime.split(':')[0]
            dic[hour]=dic[hour]+1
    
        conn.close()
    
        print(dic)
    # 开始
    main()

    统计后的数据为:

    {'00': 0, '01': 0, '02': 0, '03': 0, '04': 0, '05': 0, '06': 0, '07': 0, '08': 1, '09': 34, '10': 39, '11': 30, '12': 32, '13': 0, '14': 22, '15': 38, '16': 0, '17': 0, '18': 0, '19': 0, '20': 0, '21': 58, '22': 46, '23': 0}

    展现出来则是:

    另附上几个ID的统计图,通过这些活跃时间图可以观察出他们一个方面的用户行为:

  • 相关阅读:
    IM服务器架构实现
    TCP打洞技术
    Java的守护线程与非守护线程
    SQL中时间为空的处理小结
    tfs
    Silverlight技术总结
    PMS
    Silverlight的TabControl的selectionChanged事件中读取不到TextBox值的bug。
    hahahahahah
    APM文章
  • 原文地址:https://www.cnblogs.com/heyang78/p/8962201.html
Copyright © 2011-2022 走看看