国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

基于python生成英文版詞云圖代碼實例

瀏覽:3日期:2022-07-25 13:47:32

 使用wordcloud模塊,生成云圖,測試文本為:

Betty Botter bought some butter but she said the butter’s bitter. If I put it in my batter it will make my batter bitter. So, she bought some better butter, better than the bitter butter and she put it in her batter and her batter was not bitter. So ’twas good that Betty Botter bought some better butter.

生成云圖代碼:

#導(dǎo)入生成云圖模塊from wordcloud import WordCloudwith open('F:/python入門/數(shù)據(jù)2/fenci_test2.txt' ,encoding='utf-8')as file: #讀取文本 text=file.read() #設(shè)置詞云的字體、背景顏色、寬、高、字數(shù) wordcloud=WordCloud(font_path='C:/Windows/Fonts/Tahoma.ttf', background_color='black',width=600, height=300,max_words=50).generate(text) #生成圖片 image=wordcloud.to_image() #顯示圖片 image.show()

結(jié)果:

基于python生成英文版詞云圖代碼實例

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標簽: Python 編程
相關(guān)文章:
主站蜘蛛池模板: 牙克石市| 珲春市| 韶关市| 桐柏县| 古丈县| 瑞金市| 宝丰县| 垣曲县| 晋州市| 阜南县| 南昌县| 南召县| 莲花县| 苏尼特左旗| 威海市| 炎陵县| 永平县| 田阳县| 保靖县| 平山县| 新宾| 尚志市| 通海县| 滨州市| 龙泉市| 丘北县| 商城县| 罗平县| 曲周县| 长泰县| 精河县| 辽中县| 砀山县| 安新县| 清徐县| 遵化市| 漾濞| 泸定县| 鹤壁市| 六枝特区| 黄石市|