for line in fileinput.FileInput("file.txt", inplace=1):
if "success" in line:
print(line)
When I use fileinput, the file 'file.txt' is not released. I could see the issue 'file.txt' still in use. When I do the above function using normal file operation , no issue is shown
How to fix the issue with fileinput.
I used the below code snippet , but the issue is showing again . The file is not getting closed I guess
f = fileinput.input("file.txt", inplace=1)
for line in f:
if "success" in line:
print(line)
f.close()