基礎python學習筆記6 一些好用的庫

2022-03-03 12:16:50 字數 1336 閱讀 3102

>>>w=wordcloud.wordcloud(width=600)
>>>w=wordcloud.wordcloud(height=400)
>>>w=wordcloud.wordcloud(min_font_size=10)
>>>w=wordcloud.wordcloud(max_font_size=20)
>>>w=wordcloud.wordcloud(font_step=2)
>>>w=wordcloud.wordcloud(font_path="msyh.ttc")//微軟雅黑字型
>>>w=wordcloud.wordcloud(max_words=20)
>>>w=wordcloud.wordcloud(stop_words=)
>>>from scipy.misc import imread()

>>>mk=imread("pic.png")

>>>w=wordcloud.wordcloud(mask=mk)

>>>w=wordcloud.wordcloud(background_color="white")
1、分隔:以空格分割單詞

2、統計:單詞出現次數並過濾次數特別少的

3、字型:根據統計配置字型大小

4、布局:顏色環境尺寸

優秀的中文分詞第三方庫qwq(應用原因是中文文字需要通過分詞獲得單個詞語)

一些常見使用:

乙個小例項——詞頻統計

def gettext():

txt = open("hamlet.txt","r").read()

txt = txt.lower()

for ch in '!"#''' :

txt = txt.replace(ch, " ")

return txt

hamlettxt = gettext()

words = hamlettxt.split()

counts = {}

for word in words :

counts[word] = counts.get(word,0) + 1

items = list(counts.items())

items.sort(key=lambda x:x[1], reverse=true)

print(items)

學習筆記 一些基礎

sudo nvidia docker run ti ipc host name network host v home data workspace ce893比如 import skimage.io as io image io.imread image dir astype float 這樣得到...

學習python的一些基礎普及

我很納悶,為什麼連python這樣的開源 國內對它的官網要遮蔽掉,簡直匪夷所思!不知道是不是我的dns服務商的問題。python 官網 有時候這官網能上,有時候卻不能被遮蔽掉了。包含了各個版本python 以及python的安裝包,原始碼包和chm幫助文件 中文幫助文件,推薦入門級的看這裡 pyth...

Python基礎學習的一些記錄

file1 open users baoxiao desktop test score.txt r encoding utf 8 readlines 會從txt檔案取得乙個列表,列表中的每個字串就是scores.txt中的每一行。而且每個字串後面還有換行的 n符號。filelines file1.r...