I want to edit a a big file in specific lines.So it isnt a good Idea to read the whole file before editing, thats why I dontwant to use:
myfile.readlines()
I have to read each line check if there a special content in it and then i have to edit this line.
So far Im reading every line:
file = open("file.txt","r+")i = 0for line in file: if line ......: //edit this line //this is where i need helpfile.close()
So the Question is:How can I edit the current line in the If Statement for example:if the current line is "test" I want to replace it with "test2" and then write "test2" back into the file into the line where "test" was before