mywordCloud.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:warWolf 作者: wu-yy 项目源码 文件源码
def get_all_keywords(file_name):
    word_lists=[]  #?????
    with codecs.open(file_name,'r',encoding='utf-8') as f:
        Lists=f.readlines()
        for li in Lists:
            cut_list=list(jieba.cut(li))
            for word in cut_list:
                word_lists.append(word)

    word_lists_set=set(word_lists)  #???????
    sort_count=[]
    word_lists_set=list(word_lists_set)

    length=len(word_lists_set)
    print(u'??%d????'%length)
    k = 1
    for w in word_lists_set:
        sort_count.append(w + u':' + str(word_lists.count(w)) + u"?\n")
        print(u"%d---" % k + w + u":" + str(word_lists.count(w)) + u"?")
        k += 1
    with codecs.open('count_word.txt', 'w', encoding='utf-8') as f:
        f.writelines(sort_count)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号