Python WordCloud入门攻略
1、到lfd.uci.edu/~goh盟敢势袂lke/pythonlibs/#worldcloud里面下载与电脑系统和python版本枷讹般身相对应的wordcloud模块,具体安装步骤可以参考《怎么为python安装wordcloud模块?》
2、准备一个txt文档,里面全是英文。
3、制作文字云:from wordcloud import WordCloudf = open('0.txt','r').read()wd = WordCloud(background_color='white', width=500,height=365, margin=2).generate(f)wd.to_file('0.jpg')
4、准备一张图片,作为文字云的背景图案。
5、用上图为背景,绘制文字云:from wordcloud import WordCloudimport cv2f = open(&垆杪屑丝#39;0.txt','r').read()mk = cv2.imread('0.png')wd = WordCloud(mask=mk,background_color='white', width=500,height=365, margin=2).generate(f)wd.to_file('000.png')
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:40
阅读量:31
阅读量:71
阅读量:72
阅读量:25