There is already a question on SO that explains how to insert a line into the middle of a python file at a specific line number.
But what if I have 2 files. inputfile.txt
and outputfile.txt
(which already has some text) and I want to insert all of inputfile.txt
(with formatting preserved) into the middle of outputfile.txt
?