去除文本中的空行

#coding=utf-8
"""
anthor:wanggang
date:Jan,7,2020
"""
str=''
path='C:\\Users\\Administrator\\Desktop\\过度用\\dealdata.txt'
file=open('testmid.txt','w',encoding='utf-8')
f=open(path,'r',encoding='utf-8')
for i in f.readlines():
    if len(i)==1:#这个1这里认为是'\n'
        continue
    else:
        file.write(i)
file.close()

你可能感兴趣的:(nlp,nlp)