标签: python file overwrite
问题: 读取线后如何在一个文件中覆盖一行?
不创建新文件或读取孔文件,因为文件有123.500行。
for line in source: newline = "+" + line #write over the line in the file with newline
line =“HAHA”, newline =“+ HAHA”
如何在文件中用换行替换换行符?
答案 0 :(得分:2)
无论
fileinput模块可以为您提供帮助,如this answer