<commit_before>---
layout: single
title: "12行Python代码回复微信拜年"
header:
  teaser: "/assets/images/unsplash-gallery-image-2-th.jpg"
  overlay_color: "#000"
  overlay_filter: "0.5"
  overlay_image: /assets/images/unsplash-image-30.jpg
  cta_label: "Read More"
  caption: "Photo credit: [**Unsplash**](https://unsplash.com)"
excerpt: "On the other hand a single high impact paper is worth many low impact papers, so from a career perspective it’s not necessarily a waste of time to devote a year or two to getting something into a top journal."
modified: 2017-01-28 12:49:48
comments: true
author: "王成军"
tags:
  - wechat
categories:
  - python
---

今天上午在朋友圈读到了[《12行Python代码，自在随心应付微信拜年群发》](https://zhuanlan.zhihu.com/p/25034403)一文，非常简单，主要是借助于两个python的包 itchat和pillow，可以使用pip安装。

```terminal
pip install itchat pillow
```

[itchat](https://github.com/littlecodersh/ItChat)是 `A complete and graceful API for Wechat`. 微信个人号接口、微信机器人及命令行微信，三十行即可自定义个人号机器人。了解更多使用方法，可以阅读使用[文档 ](http://itchat.readthedocs.io )。

我在Mac上运行以下代码:

```python
# -*- coding:utf-8 -*-
import itchat, time, re
from itchat.content import *
<commit_msg>wechat4<commit_after>---
layout: single
title: "12行Python代码回复微信拜年"
header:
  teaser: "/assets/images/unsplash-gallery-image-3-th.jpg"
  overlay_color: "#000"
  overlay_filter: "0.5"
  overlay_image: /assets/images/unsplash-image-8.jpg
  cta_label: "Read More"
  caption: "Photo credit: [**Unsplash**](https://unsplash.com)"
excerpt: "今天上午在朋友圈读到了[《12行Python代码，自在随心应付微信拜年群发》](https://zhuanlan.zhihu.com/p/25034403)一文，非常简单，主要是借助于两个python的包 itchat和pillow，可以使用pip安装。"
modified: 2017-01-28 12:49:48
comments: true
author: "王成军"
tags:
  - wechat
categories:
  - python
---

今天上午在朋友圈读到了[《12行Python代码，自在随心应付微信拜年群发》](https://zhuanlan.zhihu.com/p/25034403)一文，非常简单，主要是借助于两个python的包 itchat和pillow，可以使用pip安装。

```terminal
pip install itchat pillow
```

[itchat](https://github.com/littlecodersh/ItChat)是 `A complete and graceful API for Wechat`. 微信个人号接口、微信机器人及命令行微信，三十行即可自定义个人号机器人。了解更多使用方法，可以阅读使用[文档 ](http://itchat.readthedocs.io )。

我在Mac上运行以下代码:

```python
# -*- coding:utf-8 -*-
import itchat, time, re
from itchat.content import *

{'fraction_non_alphanumeric': 0.14399624765478425, 'fraction_numerical': 0.0375234521575985, 'mean_word_length': 5.463636363636364, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 7, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1665073', 'n_tokens_mistral': 1069, 'n_tokens_neox': 1042, 'n_words': 164}