• WordCloud安装


    1,下载

    https://www.lfd.uci.edu/~gohlke/pythonlibs/#wordcloud

    2,安装    (window环境安装)

    找的下载文件的路径   

    安装  

    1
    pip install wordcloud-1.3.2-cp36-cp36m-win_amd64.whl

      

    3,验证是否安装成功

    添加英文数据的文件,比如我的是testfile.txt

    文件内容为英文,比如

    Devouring Time, blunt thou the lion's paws,

    And make the earth devour her own sweet brood;

    Pluck the keen teeth from the fierce tiger's jaws,

    And burn the long-lived phoenix in her blood;
    。。。。。。。。

    运行python:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    from wordcloud import WordCloud
     
    f = open(u'D:PythonWorkspaceAI/testfile.txt''r').read()
     
    wordcloud = WordCloud(background_color="white", width=1000, height=860, margin=2).generate(f)
    import matplotlib.pyplot as plt
     
    plt.imshow(wordcloud)
    plt.axis("off")
    plt.show()wordcloud.to_file('test1.png')//保存图片

    结果

    如果还有问题未能得到解决,搜索887934385交流群,进入后下载资料工具安装包等。最后,感谢观看!

  • 相关阅读:
    【BJOI2018】求和
    【洛谷P1613】跑路
    【NOI2001】食物链
    【NOI2002】银河英雄传说
    【POJ1456】Supermarket
    【NOIP2013】货车运输
    【CH#56C】异象石
    【POJ3417】Network
    【APIO2010】巡逻
    【CH6201】走廊泼水节
  • 原文地址:https://www.cnblogs.com/pypypy/p/11732213.html
Copyright © 2020-2023  润新知