I know that many questions exist here on finding and replacing text in file using python 2. However being a very new to python, I did not understand the syntax and may be the purpose also will be different.
I am looking for something very simple code lines as in linux shellscript
sed -i 's/find/replace/' *.txt
sed -i 's/find2/replace2/' *.txt
Can this code work to replace a multiline text
with open('file.txt', 'w') as out_file:
out_file.write(replace_all('old text 1', 'new text 1'))
out_file.write(replace_all('old text 2', 'new text 2'))
Also, there seems a problem with getting another newline, which I do not want. Any ideas or help?