def add_spam_dict_1dict0 pathDir = oslistdirtest-spam-1 for s in pathDir new_dir=ospathjointest-spam-1s #将文件命加入到当前文件路径后面 if ospathisfilenew_dir #如果是文件 w
这段代码实现的功能是读取指定文件夹内的所有文件,对每个文件进行分词,并将分词结果添加到给定的字典(dict0)中。如果分词结果已经存在于字典中,则将对应键的值加1。
原文地址: https://www.cveoy.top/t/topic/flSV 著作权归作者所有。请勿转载和采集!