三年前写的文章,阅读量暴涨了6.8万。。。

简介: 三年前写的文章,阅读量暴涨了6.8万。。。

这里统计了互发消息条数前十名的好友,出于隐私就不放名字了。

可以看出几点信息:

  • 常聊天的好友主要有3位,再后面的就出现断崖式下降了。
  • 今年我回复的消息远远不及接收的消息多,对比前两年,我是回复大于接收的。(难道说今年我变高冷了?)
  • 相比前两年,前三名是新面孔,很多之前的老面孔都退出了前10名,工作了之后确实聊的少了。
  • 好友6的回复条数尤其少,大概接收10条才回复1条,在我粉丝群的老粉应该都能猜出这是谁。

一年中聊天数量趋势

从2022.1.1开始统计到2022.11.11为止,我画出了每一天私聊互发消息条数的趋势图。

这张图有很大的信息量:

  • 年初到过年期间(0-60天)越聊越多,可能过年在家无聊吧。
  • 上海封城期间(60-140天)越聊越少,封城后期天天打游戏,都快自闭了吧可能。
  • 5月底(140天)开始,消息量急速上升,因为遇见了一个改变了我许多的人。
  • 678三个月(140-230天),消息量急速下降直到正常,毕竟不可能一直维持刚开始的热情的,那不得累死。
  • 9月份(230-270天),消息量又上升了一点,可能是因为要回了吧。
  • 10月份(270-300天),消息量降到全年最低,因为不需要网聊了吧。
  • 再往后又上升至正常,因为又回到上半年的状态了吧。

这里不深入分析了,等一个月后的年终总结吧。不管怎么样,感谢吧。

一天中几点聊的最多?

这个趋势和前两年是一样的,我仍然是一个夜猫子。夜越深,聊的越嗨,半夜12点是我聊的最嗨的时候。而中午和下午是聊的最少的时候,因为要上班。

我最喜欢发什么词?

可以看出发的最多的词是:肯定、确实、哦哦哦、喜欢、感觉。

实现方法

首先你得有一个mac电脑,然后用下面方法导出聊天记录,并且都存放在jsons目录下:

超简单:mac导出微信聊天记录(附上粉丝群全部聊天记录)

然后用下面的代码导出你所有的私聊记录,保存到output.txt文件中。

import json
import os
files = os.listdir("jsons")
fout = open("output.txt", "w")
for f in files:
    with open(f"jsons/{f}", "r") as fin:
        print(f)
        results = json.load(fin)
        is_group = 1
        for dic in results:
            if (
                dic["messageType"] == 1
                and dic["msgCreateTime"] >= 1640966434
                and dic["msgStatus"] != 2
                and dic["mesDes"] == 1
                and ":" not in dic["msgContent"]
            ):
                is_group = 0
                break
        if not is_group:
            for dic in results:
                if (
                    dic["messageType"] == 1
                    and ":" not in dic["msgContent"]
                    and dic["msgCreateTime"] >= 1640966434
                    and dic["msgStatus"] != 2
                ):
                    content = "".join(dic["msgContent"].strip().split())
                    if dic["mesDes"] == 1:
                        fout.write(
                            "{} 1 {} {}\n".format(f, str(dic["msgCreateTime"]), content)
                        )
                    else:
                        fout.write(
                            "{} 0 {} {}\n".format(f, str(dic["msgCreateTime"]), content)
                        )
fout.close()

最后用下面代码分析本文中提到的几点要素,注意改一下中文字体路径。最后还会生成me.txt,可以用来生成词云,生成方法参考之前的文章。

python生成词云教程(附带QQ聊天记录生成词云实战)

import datetime
from collections import defaultdict
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
import matplotlib.font_manager
def getChineseFont():
    # 去你电脑的字体库找一个中文字体,把文件路径粘贴过来
    return FontProperties(fname="/System/Library/Fonts/PingFang.ttc", size=20)
matplotlib.rcParams["pdf.fonttype"] = 42
matplotlib.rcParams["ps.fonttype"] = 42
# 2022.1.1 00:00
start = 1640966434
def process_time(end):
    t = datetime.datetime(2022, 1, 1, 0, 0, 0) + datetime.timedelta(seconds=end - start)
    return (t.month, t.day, t.hour, t.minute, t.second)
"""跟谁聊的最多
姓名 总共 发送 接收
"""
name_count = defaultdict(int)
send_count = defaultdict(int)
rece_count = defaultdict(int)
with open("output.txt", "r") as fin:
    for line in fin:
        name = line.strip().split(" ")[0]
        des = int(line.strip().split(" ")[1])
        name_count[name] += 1
        if des == 0:
            send_count[name] += 1
        else:
            rece_count[name] += 1
nc = sorted(name_count.items(), key=lambda x: x[1], reverse=True)
for k in nc[:10]:
    print(k[0], k[1], send_count[k[0]], rece_count[k[0]])
c1 = [x[1] for x in nc[:10]]
c2 = [send_count[x[0]] for x in nc[:10]]
c3 = [rece_count[x[0]] for x in nc[:10]]
r = np.arange(len(c1))
plt.figure(figsize=(8, 6))
plt.plot(r, c1, color="red", label="Total", linewidth=2.0)
plt.plot(r, c2, color="green", label="Send", linewidth=2.0)
plt.plot(r, c3, color="blue", label="Receive", linewidth=2.0)
plt.yticks(fontsize=20)
plt.xlabel("姓名", fontproperties=getChineseFont(), fontsize=20)
plt.ylabel("消息条数", fontproperties=getChineseFont(), fontsize=20)
plt.legend(fontsize=20)
plt.savefig("./name_count.pdf", bbox_inches="tight")
plt.show()
"""哪个月份聊的最多
月份 数量
"""
month_count = defaultdict(int)
with open("output.txt", "r") as fin:
    for line in fin:
        time = int(line.strip().split(" ")[2])
        t = process_time(time)
        month_count[t[0]] += 1
mc = sorted(month_count.items(), key=lambda x: x[1], reverse=True)
for k in mc:
    print(k[0], k[1])
mc = sorted(month_count.items(), key=lambda x: x[0], reverse=False)
x_ticks = [x[0] for x in mc]
c = [x[1] for x in mc]
r = np.arange(len(c))
plt.figure(figsize=(8, 6))
plt.plot(r, c, color="red", linewidth=2.0)
plt.xticks([r for r in range(len(c))], x_ticks, fontsize=20)
plt.yticks(fontsize=20)
plt.xlabel("月份", fontproperties=getChineseFont(), fontsize=20)
plt.ylabel("消息条数", fontproperties=getChineseFont(), fontsize=20)
plt.legend(fontsize=20)
plt.savefig("./month_count.pdf", bbox_inches="tight")
plt.show()
"""哪个时间点聊的最多
几点 数量
"""
hour_count = defaultdict(int)
with open("output.txt", "r") as fin:
    for line in fin:
        time = int(line.strip().split(" ")[2])
        t = process_time(time)
        hour_count[t[2]] += 1
hc = sorted(hour_count.items(), key=lambda x: x[1], reverse=True)
for k in hc:
    print(k[0], k[1])
hc = sorted(hour_count.items(), key=lambda x: x[0], reverse=False)
x_ticks = [x[0] for x in hc]
c = [x[1] for x in hc]
r = np.arange(len(c))
plt.figure(figsize=(14, 6))
plt.plot(r, c, color="red", linewidth=2.0)
plt.xticks([r for r in range(len(c))], x_ticks, fontsize=20)
plt.yticks(fontsize=20)
plt.xlabel("小时", fontproperties=getChineseFont(), fontsize=20)
plt.ylabel("消息条数", fontproperties=getChineseFont(), fontsize=20)
plt.legend(fontsize=20)
plt.savefig("./hour_count.pdf", bbox_inches="tight")
plt.show()
"""哪一天聊的最多
"""
day_count = defaultdict(int)
with open("output.txt", "r") as fin:
    for line in fin:
        time = int(line.strip().split(" ")[2])
        t = process_time(time)
        day_count[t[0] * 31 + t[1]] += 1
dc = sorted(day_count.items(), key=lambda x: x[0], reverse=False)
c = [x[1] for x in dc]
r = np.arange(len(c))
plt.figure(figsize=(14, 6))
plt.plot(r, c, color="red", linewidth=2.0)
plt.yticks(fontsize=20)
plt.xlabel("第几天", fontproperties=getChineseFont(), fontsize=20)
plt.ylabel("消息条数", fontproperties=getChineseFont(), fontsize=20)
plt.legend(fontsize=20)
plt.savefig("./day_count.pdf", bbox_inches="tight")
plt.show()
"""我最喜欢发什么词?
"""
with open("output.txt", "r", encoding="utf-8") as fin, open("me.txt", "w", encoding="utf-8") as fout:
    for line in fin:
        des = int(line.strip().split(" ")[1])
        if des == 0:
            content = line.strip().split(" ")[3]
            fout.write(content + "\n")
相关文章
|
9月前
|
算法 前端开发 Java
面试机会增加100倍,建议收藏!
面试机会增加100倍,建议收藏!
88 0
淘宝预售“买崩”程序员20分钟修复,全靠这份亿级流量并发手册
朋友们,今年双11电商大促即将到达,感受到四面八方激动的心情没有? 去年天猫淘宝在双十一中订单可是破了58.3万笔/秒,预测一波今年成交额又会打破去年记录。作为一名互联网民工,我关心的不是订单有多少,而是系统竟然没崩!以及这背后为了抗住这巨大的并发量的程序员同胞们……
|
前端开发 架构师 Java
晚上不用加班了,推荐十款精选IntelliJIdea插件,效率提升N倍
晚上不用加班了,推荐十款精选IntelliJIdea插件,效率提升N倍
晚上不用加班了,推荐十款精选IntelliJIdea插件,效率提升N倍
|
人工智能 Kubernetes 大数据
2022年春招最新消息:IT互联网行业平均薪资18500元!
2022年春招最新消息:IT互联网行业平均薪资18500元!
288 0
|
达摩院
【非广告】半年时间 90% 的收益就问你慌不慌
先说明这篇文章不包含任何广告内容,也不提供任何投资理财建议,股市有风险,投资需谨慎! 都说牛市来了,今年的 A 股的行情确实很不错,从上面的截图中可以看到阿粉的一只基金已经收益 90% 了。90% 是什么概念,反正阿粉是没有过的,估计很多人都没有经历过这种收益,所以这几天阿粉慌的一批,除了慌的很之外,另一个就是懊悔的很,当初应该多买点的,只能说人性是贪婪的。
【非广告】半年时间 90% 的收益就问你慌不慌
|
开发工具 网络虚拟化 Android开发
用盾的如果明白这一点,人气能暴涨!!
用盾的如果明白这一点,人气能暴涨!!
用盾的如果明白这一点,人气能暴涨!!
|
人工智能 自然语言处理 搜索推荐
增长难题如何破?20天后引擎大会或给出“答题指引”
增长难题如何破?20天后引擎大会或给出“答题指引”
219 0
增长难题如何破?20天后引擎大会或给出“答题指引”
|
机器人 UED
这部手机刚上市价格就暴涨60%,但看了黑科技彩蛋感觉真的值!
在国外一直比国内更吃香的一加公司,最近刚推出了其新的全面屏手机一加 5T,相比前代配置基本没变,重点只是升级了最近流行的“全面屏”。
113 0
这部手机刚上市价格就暴涨60%,但看了黑科技彩蛋感觉真的值!
|
新零售 NoSQL 容灾
业务爆发保持丝般顺滑 阿里云助力完美日记半年内系统吞吐量提升50倍
近年来,完美日记的“小黑钻口红”“动物眼影盘”等爆款彩妆出现在了越来越多女孩子的化妆台上,完美日记(Perfect Diary)是由逸仙电商在2017年推出的彩妆品牌,凭借着高颜值和性价比,完美日记彩妆销量增长迅猛,被众多网友誉为国货之光。
752 0
业务爆发保持丝般顺滑 阿里云助力完美日记半年内系统吞吐量提升50倍