Python 去除文件中的空行

def clear_space():
with open("test","r",encoding="utf-8") as fr:
for line in fr:
line = line.strip()
if len(line) > 0:
yield line
g = clear_space()
for line in g:
with open("test.bak","a",encoding="utf-8") as fw:
fw.write(line+"\n") ```
上一篇:PHP总结


下一篇:bootstrap学习总结-06 按钮