---
name: Txt2WordCloud
slug: txt2wordcloud
category: Data
description: Txt2WordCloud generates a word cloud image from a text file. Use it when you need word frequency visualization with a custom background color.
github: "https://github.com/CoderWanFeng/python-office/tree/develop/skills/image/txt2wordcloud"
language: Python
stars: 1339
forks: 301
install: "npx degit https://github.com/CoderWanFeng/python-office/tree/develop/skills/image/txt2wordcloud ~/.claude/skills/txt2wordcloud"
installs_to: ~/.claude/skills/txt2wordcloud
source_path: skills/image/txt2wordcloud/SKILL.md
collection_size: 50
category_size: 668
collection_url: "https://dirskills.com/collections/CoderWanFeng/python-office"
added: 2026-08-12T04:43:06.026Z
last_synced: 2026-08-12T04:43:06.026Z
canonical_url: "https://dirskills.com/skills/txt2wordcloud"
---

# Txt2WordCloud

Txt2WordCloud generates a word cloud image from a text file. Use it when you need word frequency visualization with a custom background color.

**Install:**

```bash
npx degit https://github.com/CoderWanFeng/python-office/tree/develop/skills/image/txt2wordcloud ~/.claude/skills/txt2wordcloud
```

## README

# txt2wordcloud Skill

> 根据指定的文本文件生成词云图像

## 功能描述

根据指定的文本文件内容，生成词云图片。

## 所属分类

`office/skills/image/txt2wordcloud/`

## 调用方式

```python
from skills.image import txt2wordcloud

txt2wordcloud(
    filename='./text.txt',
    color='white',
    result_file='wordcloud.png'
)
```

## 参数说明

| 参数 | 类型 | 必填 | 默认值 | 说明 |
|------|------|------|--------|------|
| `filename` | str | 是 | - | 文本文件的路径 |
| `color` | str | 否 | `"white"` | 词云的背景颜色 |
| `result_file` | str | 否 | `"your_wordcloud.png"` | 生成的词云图像文件名 |

## 返回值

`None`

## 使用示例

```python
from skills.image import txt2wordcloud
txt2wordcloud(filename='./article.txt', result_file='./my_wordcloud.png')
```

## 原始函数

`office.api.image.txt2wordcloud`
