from collections import Counter
import jieba
import jieba.posseg
from jieba import analyse
import sys
#jieba.suggest_freq(‘乡村小规模学校‘, True)
import re
import importlib
import linecache
f1 = open("C:\\Users\\zyl\\Desktop\\test.txt","r",encoding=‘utf-8‘)
buff = f1.readlines()
f2 = open("C:\\Users\\zyl\\Desktop\\printout.txt",‘w+‘,encoding=‘utf-8‘)
dataSet = []
flag = False
sentence = r‘(\s)‘
for line in buff:
if line:
for i in line:
result = re.findall(sentence,i)
if result:
continue
else:
dataSet.append(i)
else:
continue
dataSet.append("\n")
cache_str = "".join(dataSet)
cache_list = cache_str.split("\n")
for j in range(len(cache_list)):
if cache_list[j]:
f2.write(cache_list[j]+‘\n‘)
else:
continue
f2.close()
f3 = open("C:\\Users\\zyl\\Desktop\\printout.txt",‘r+‘,encoding=‘utf-8‘)
result = f3.read()
print(result)