使用python实现\记事本中去除掉空行数据
代码如下:"""读取存在空行的文件,删除其中的空行,并将其保存到新的文件中"""def rewrite(): with open('src-test.txt','r',encoding = 'utf-8') as fr,open('newsrc-test.txt','w',encoding = 'utf-8') as fd: for text in fr.readlines(): if text.split():