2024年06月03日 建站教程
如何利用Python
语法生成一个词云,下面web建站小编给大家简单介绍一下具体实现代码!
具体代码如下:
pip install wordcloud pip install jieba pip install matplotlib import matplotlib.pyplot as plt from wordcloud import WordCloud import jieba text_from_file_with_apath = open('/Users/ciyun/example.txt').read() wordlist_after_jieba = jieba.cut(text_from_file_with_apath, cut_all = True) wl_space_split =.join(wordlist_after_jieba) my_wordcloud = WordCloud().generate(wl_space_split) plt.imshow(my_wordcloud) plt.axis(off) plt.show()
本文链接:http://so.lmcjl.com/news/5844/