#说明:1、用来处理文件输出到指定位置
2、统计关键词个数
import os
#输入:内容/路径
#输出:文件
def outText(str,route):
if os.path.isfile(route):
os.remove(route)
fp = open(route,'w')
fp.write(str)
fp.close()
#输入:文本内容/关键词
#输出:统计个数
def countNum(text,keyword):
i=0
count=0
while(True):
j = text[i:].find(keyword,0)
if j>=0:
count += 1
i += j+1
else:
break
return count