with open 向文件的某一固定行,追加内容
with open(r"D:\RSU地图制作\1-南京\111111","r") as f: lines = f.readlines() lines.insert(3,"向第四行,加入的内容") s = "".join(lines) with open(r"D:\RSU地图制作\1-南京\111111","w") as f: f.write(s)
with open(r"D:\RSU地图制作\1-南京\111111","r") as f: lines = f.readlines() lines.insert(3,"向第四行,加入的内容") s = "".join(lines) with open(r"D:\RSU地图制作\1-南京\111111","w") as f: f.write(s)