python学习之词云图片生成

在这里插入图片描述

代码实现

import jieba
import wordcloud

f = open("D:/Pythonstudy/data/平凡的世界.txt", "r", encoding="utf-8")
t = f.read()
print(t)
f.close()
ls = jieba.lcut(t)
txt = " ".join(ls)

w = wordcloud.WordCloud(
    font_path="D:/ccc/Fonts.TTF", width = 1000, height = 700, background_color = "white",mode="RGBA")
w.generate(txt)
w.to_file("pfdsj.png")

遇见问题

中文字体生成词云图片时会生成矩形框,解决办法:引入本地的字体

相关推荐

  1. Python文本数据可视化”图

    2024-05-02 14:28:09       33 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-05-02 14:28:09       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-05-02 14:28:09       106 阅读
  3. 在Django里面运行非项目文件

    2024-05-02 14:28:09       87 阅读
  4. Python语言-面向对象

    2024-05-02 14:28:09       96 阅读

热门阅读

  1. STM32 单片机 GPIO 的八种工作模式是什么?

    2024-05-02 14:28:09       32 阅读
  2. Linux常用命令总结

    2024-05-02 14:28:09       37 阅读
  3. 数据结构-二叉树的遍历

    2024-05-02 14:28:09       33 阅读
  4. JDBC连接流程

    2024-05-02 14:28:09       30 阅读
  5. 普通类和抽象类

    2024-05-02 14:28:09       31 阅读
  6. Element UI 简介

    2024-05-02 14:28:09       33 阅读
  7. 【leetcode】缓存淘汰策略题目总结

    2024-05-02 14:28:09       35 阅读
  8. CentOS-Stream-9配置网络和web控制台cockpit

    2024-05-02 14:28:09       28 阅读
  9. Redis从入门到精通

    2024-05-02 14:28:09       31 阅读
  10. LLM - 模型参数设置

    2024-05-02 14:28:09       39 阅读