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") ```
相关文章
- 12-20c – LLDB Python脚本中的指针算法
- 12-20python – 如何获得Pandas中groupby之后的列计数百分比
- 12-20python中sorted和.sorted 、reversed和reverse的注意点
- 12-20python中关键字的总结
- 12-20python – Wand将pdf转换为jpeg并将页面存储在类文件对象中
- 12-20如何使用python以编程方式计算存档中的文件数
- 12-20python-是否有一种方法可以从subprocess.Popen实例中读取字符,当它调用的进程尚未发出换行符时?
- 12-20如何将rfcomm shell命令的结果放入python中的变量中?
- 12-20Python3中的super()函数详解
- 12-20python中的循环