Giter Site home page Giter Site logo

wechat's Introduction

wechat

微信好友男女比例,区域排名,签名情感分析

程序 备注 技术栈
微信好友性别占比 采集微信好友性别比例并绘制饼图 itchat, matplotlib
微信好友头像 采集微信好友头像并拼接大图 itchat, math, PIL
微信好友地区分布 采集微信好友区域分布并分别制作省会和城市Top10柱形图 itchat, matplotlib
微信好友个性签名情感分析 采集微信性别比例并绘制饼图 itchat, matplotlib, jieba, numpy, snownlp, wordcloud
import itchat

itchat.auto_login(hotReload=True)
itchat.dump_login_status()
we_friend = itchat.get_friends(update=True)[:]

返回的结果we_friend是微信好友的基本信息列表, 单个好友字典的 key 如下表:

key 备注
UserName 微信系统内的用户编码标识
NickName 好友昵称
Sex 性别
Province 省份
City 城市
HeadImgUrl 微信系统内的头像URL
RemarkName 好友的备注名
Signature 个性签名

通过统计好友人数、男生女神各多少人算出好友性别占比,再绘制饼图。

  • 首先需要把好友头像保存在同一目录

  • 设定最后拼图的大小,以及每行需要拼接几个头像,这里我采用图片的面积除以图片的张数

each_size = int(math.sqrt(float(640 * 640) / len(ls)))  # 算出每张图片的大小多少合适
lines = int(640 / each_size)
image = Image.new('RGBA', (640, 640))   # 创建640*640px的大图

微信好友头像

  • 由于地区太多,故使用Python sorted函数进行排序,对地区和城市Top10进行柱状图展示

微信好友城市Top10

微信好友区域Top10

通过区域和城市人数排名,其实大致看出你的户籍所在地和工作地点了。

这里主要做了两部分

  • 第一部分使用jieba分词对好友个性签名进行切词,并制作词云图,这里的词云图背景使用比较火的小猪佩奇

好友个性签名词云图

  • 第二部分使用snownlp对好友的签名做一个简单的情感分析

好友个性签名情感值分布

通过饼图来推测我的好友大多数正向情感要高于负向情感。

最后, 想一块合作做更多有趣好玩的项目,欢迎关注公众号:

Python攻城狮

wechat's People

Contributors

reainl avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.