下面展示**:
"""
import jieba
s ="python是最有意思的程式語言"
ls =
[item for item in jieba.
cut(s)
]print
(ls)
""""""
import jieba
s ="今天晚上我吃了義大利面"
jieba.
add_word
("義大利面"
)ls =
[item for item in jieba.
cut(s)
]print
(ls)
"""import jieba
from wordcloud import wordcloud
f =open
("明朝那些事兒.txt"
,"rt"
,encoding=
"utf-8"
)txt = f.
read()
f.close()
exclusions =
["com"
,"href"
,"shuyaya"
,"**網"
,"**"
,"乙個"
,"沒有"
,"這個"
,"他們"
,"就是"
,"files"
,"article"
,"caizi"
,"已經"
,"**"
,"不是"
,"因為"
,"**"
,"這樣"
,"這位"
,"事情"
,"什麼"
,"冬裝"
,"夏裝"
,"十分"
,"我們"
,"這些"
,"還是"
,"可以"
,"雖然"
,"終於"
,"知道"
,"實在"
,"如果"
,"之後"
,"天貓"
,"問題"
,"於是"
,"開始"
,"時候"
,"12"
,"this"
,"準備"
,"只是"
,"所以"
,"很多"
,"似乎"
,"現在"
,"不能"
,"可是"
,"成為"
,"最後"
,"然而"
,"這是"
,"此時"
,"應該"
,"裙子"
,"購物"
,"一次"
,"這種"
,"當時"
,'可能'
,"能夠"
,"所有"
,"還有"
,"所謂"
,"這裡"
,"大家"
,"先生"
,"為了"
,'只有'
,'竟然'
,'士兵'
,'如此'
,'軍隊'
,'不會'
,'那個'
,'發現'
,'兩個'
,'兒子'
,'不過'
,'那些'
,'確實'
,'一定'
,'地方'
,'決定'
,'正是'
,'自己'
,'這麼'
,'得到'
,'工作'
,'自然'
,'其實'
,'歷史'
,'明白'
]# print
(txt[
125100
:125200])
words = jieba.
lcut
(txt)
wordsdict =
for word in words:
iflen
(word)
==1 or word in exclusions:
continue
wordsdict[word]
= wordsdict.
get(word,0)
+1wordslist =
list
(wordsdict.
items()
)wordslist.
sort
(key=lambda x:x[1]
,reverse=true)
rank =
0for word,frequency in wordslist[:13
]:rank +=
1 info =
"詞語排名#詞語:<5}頻率統計:"
.format
(rank,word,frequency,
chr(
12288))
print
(info)
# personscontent =
[(word+
' ')
*frequency for word,frequency in wordslist[:13
]] personscontent =
for word,frequency in wordslist[:13
]:for i in
range
(frequency)
: personscontent.
(word)
personstxt =
" ".
join
(personscontent)
wordcloud =
wordcloud
(font_path=
"msyh.ttf"
,collocations=false,max_words=13)
.generate
(personstxt)
wordcloud.
to_file
("明朝那些事兒.png"
計算機考試二級
計算機二級是全國計算機等級考試 nationalcomputerrankexamination,簡稱ncre 四個等級中的乙個等級,是經原國家教育委員會 現教育部 批准,由教育部考試中心主辦的用於考查應試人員計算機應用知識與技能的全國性計算機水平考試。計算機二級考試不僅考核計算機基礎知識,還有計算機...
python計算機二級考試大題總結
1.賣火柴的小女孩 2.節假日讀入 csv檔案處理 3.論語 文章處理 4.感測器索引 5.傲慢與偏見 文章處理 6.成績統計 csv檔案處理 7.類8.凱撒密碼 9.詩詞轉換 10.猜字母遊戲 答題思路 開啟檔案 讀取檔案內容 定義字典,統計字元數量 轉化字典為列表方便排序 進行排序 寫如檔案 關...
計算機二級考試高頻考點
一.資料結構與演算法 考點一 1.1 演算法是對解題方 而完整的描述,簡單來說演算法就是解決問題的操作步驟。演算法的基本特徵 可行性確定性 有窮性擁有足夠的情報 1.2 演算法的複雜度 時間複雜度 空間複雜度 考點二 資料結構的基本概念 2.1 什麼是資料結構 資料結構是指相互有關兩的資料元素的集合...