Search And Replace Specific Line Which Starts With Specific String In A File
My requirement is to open a properties file and update the file, for update purpose i need to search for a specific string which stores the url information. For this purpose i have
Solution 1:
I'm pretty sure that this is not the best way of doing that, but this is still one way:
withopen(input_file_name, 'r') as f_in, open(output_file_name, 'w') as f_out:
for line in f_in:
if line.startswith("gStrOwsEnv"):
f_out.write(reowsURL)
else:
f_out.write(line)
That script copy every line of input_file_name
into output_file_name
except the lines that you want to change.
Post a Comment for "Search And Replace Specific Line Which Starts With Specific String In A File"