1

from wordcloud import WordCloud

import matplotlib.pyplot as plt

import jieba

from PIL import Image

import numpy as np

def create_word_cloud(words): 

   text = " ".join(jieba.cut(words,cut_all=False, HMM=True))

   wc = WordCloud( font_path="./wc.ttf", max_words=100, width=2000, height=1200, )

   wordcloud = wc.generate(text) 

   wordcloud.to_file("wordcloud.jpg") 

  plt.imshow(wordcloud)

  plt.axis("off")

  plt.show()

posted @ 2021-04-24 23:27  abl123  阅读(29)  评论(0)    收藏  举报