I'm trying to delete each line which contains "annote = {" but my code is not working.
I have a file stored in a variable myFile
and I want to go through every line of this file and delete every line which contains the string annote.
this is basically my code:
print(myFile.read()) //prints myFile
myFile.seek(0)
for lines in myFile:
if b"annote = {" in lines:
lines = lines.replace(b'.', b'')
myFile.seek(0)
print(myFile.read()) //this prints the exact same as the print method above so annote lines
//haven't been removed from this file
I have no idea why annote lines doesn't get removed. There is probably anything wrong with the replace method because it always is inside the if
request but nothing happens with annote lines. I've also tried lines.replace(b'.', b'')
instead of lines = lines.replace(b'.', b'')
but nothing happened.
Hope anyone can help me with this problem