python read line by line and keep indent

Peter Otten __peter__ at web.de
Sat Apr 18 03:49:48 EDT 2020


Souvik Dutta wrote:

> You can actually read and write in a file simultaneously. Just replace "r"
> with "w+" if the file has not been previously made or use "r+" is the file
> has already been made.

Good advice for those who like to butcher their data ;)

Seriously, writing modified data into a new file is the cleaner and safer 
method in most cases.



More information about the Python-list mailing list