# 数据可视化

数据可视化的功能,目前有:

安装:pip install python-office

# 1、文本生成词云图

视频说明:传送门

将一段文本内容,自动分析词频并生成词云图,直观展示文本中的高频词汇。

import office

office.image.txt2wordcloud(
    filename=r'D:\text\python-office.txt',  # 文本文件路径
    color='black',                           # 词云背景颜色
    result_file='your_wordcloud.png'         # 输出图片文件名
)

参数说明:

参数 类型 必填 说明
filename str 文本文件路径(.txt 格式)
color str 词云背景颜色,如 blackwhite
result_file str 输出图片文件名,默认保存在当前目录

效果示例:

词云效果


# 相关课程

Last Updated: 4/6/2026, 10:18:15 AM