+ 1

seeking in python

How can I insert text in the middle of a text file as I can't seek in the append mode?

21st Apr 2020, 6:51 PM
Ahmad Tarek
Ahmad Tarek - avatar
1 Odpowiedź
+ 6
What you can do is to read the complete file line by line in a list. Then identify the position where you want to insert the new text. Insert new data in the list, and finally write back the complete file to the hard drive.
21st Apr 2020, 7:10 PM
Lothar
Lothar - avatar