python - How can I write on new lines in a text file while preserving old ones -


when open text file , write in , @ end of program close it, lines stay in text file. when reopen program, rather writing on new set of lines, overwrites there. want keep both pieces of text, data logging. ideas on how fix this.

you should use a mode, this:

with open("file","a") f:     f.write("something")  

this append file instead of overwriting it.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -