利用python过滤去没用的词语,过滤的词语存储在停用文件中. #创建停用词表 def stopwordlist(): stopwords=[line.strip() for line in open ('F:\大数据\大作业\分词后的文件\stopWord.txt','r').readlines()] return stopwords f=open(r"F:\大数据\大作业\分词后的文件\data2_xinxi.txt",'r') s=f.read() #切割文件中的字符串 zifu
Python的字符串格式化有两种方式: 百分号方式.format方式 百分号的方式相对来说比较老,而format方式则是比较先进的方式,企图替换古老的方式,目前两者并存.[PEP-3101] This PEP proposes a new system for built-in string formatting operations, intended as a replacement for the existing '%' string formatting operator. 1.百分号