Python - 技巧 - 获得文件中单词的数目

    技术2022-05-20  38

     

    本作品采用知识共享署名-非商业性使用-相同方式共享 3.0 Unported许可协议进行许可。允许非商业转载,但应注明作者及出处。

    作者:liuyuan_jq

    2011-04-18

     

    本函数来自于GITS博客


     

    def get_words_from_filename(filename): """Get the words from filename""" split = re.compile(r"/b/w+/b").findall return [word for line in open(filename) for word in split(line.lower())] 

     


    最新回复(0)