久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

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

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

瀏覽:4日期: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è)置詞云的字體、背景顏色、寬、高、字?jǐn)?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é)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Python 編程
相關(guān)文章:
主站蜘蛛池模板: 巴中市| 桂林市| 陇南市| 全州县| 永嘉县| 农安县| 会理县| 沂水县| 宝鸡市| 南雄市| 巍山| 萨迦县| 方正县| 涿州市| 合山市| 湖州市| 彩票| 新和县| 平乡县| 宜川县| 江西省| 繁峙县| 封开县| 阿拉善左旗| 蓝山县| 堆龙德庆县| 宜君县| 英山县| 天长市| 桓仁| 鹰潭市| 德阳市| 阿勒泰市| 北安市| 云阳县| 阳高县| 阿尔山市| 台南市| 云梦县| 郑州市| 平山县|