Dear all :
i have one question on " How to import jieba.analyse " . since i have already import jieba library and it seems the " jieba library " has been successfully installed ! but when i want to import " jieba.analyse "
the result turned out to be wrong as below :
Traceback (most recent call last):
File “main.py”, line 22, in
import jeiba.analyse
ModuleNotFoundError: No module named ‘jeiba’
So my question is how to solve this problem ? and what next step should i take when i have already imported " jieba library" through hitting " Package Button " ? the 3rd question is that when you want to import 3rd party library , is it the right way to hit the " Package Button ? my Python code is as below and please kindly advise and tell me now to finish " importing jieba.analyse " ! Thank you very much !
Anakins
讀取檔案三部曲
重點一: 所有你的project都應該放在project下面(所有資源都要放在專案底下)
要用檔案路徑的時候: 用一個相對路徑去寫
用repl.it 的時候, a.txt(文字檔要直接上傳到雲端)
f = open(“a.txt”, “r”, encoding=“utf-8”) # 第一個步驟
article = f.read() # 第二個步驟, 這個文字給它一個名字叫article
f.close() # 第三個步驟
print(article)
result = {} # {} 是字典(袋子)的符號, 所以result是空的字典
for c in article:
如果對的話,是指"我們第二次以上遇到"
if c in result:
result[c] = result[c] + 1 # 這樣設定回去且這句話是屬於if的, 所以要"縮排", 裡面次數拿出來之後,加1再設定回去
錯的時候代表:我們第一次遇到
else:
result[c] = 1
print(result) # "皮"出現4次, ","出現22次, 每一個字都幫你統計完了
體驗一下jeiba(非常好用的函式庫)
import jeiba.analyse
keywords = jeiba.analyse.extract_tags(article, 5)
print(“這篇文章最關鍵的詞是:”, keywords)