I am trying to open a file and search for a particular string in a line and replace it with another string.
I am trying the following code.
def myFunct(file, test, patter, replace):
with open(file, mode='r') as f:
for line in f.readline():
if str(line).__contains__(test):
if patter in line:
print("Found here\n")
print(line)
f.close()
The code does not seem to go into the for loop. Any suggestions ?
I have also tried a similar solution with the same problem.