EvilZone

Programming and Scripting => Scripting Languages => : Ragehottie June 03, 2012, 01:28:41 AM

: [Python] Write something to a file without deleting other things
: Ragehottie June 03, 2012, 01:28:41 AM
The title says it all. I want to write a new line of text without deleting the other lines.
: Re: [Python] Write something to a file without deleting other things
: centizen June 03, 2012, 01:59:27 AM
open the file with open("filename.txt","a") instead of using "w"


puts it in append mode
: Re: [Python] Write something to a file without deleting other things
: Ragehottie June 03, 2012, 02:08:17 AM
I still get an error. I am using this code:


: (python)

filename = 'Test.txt'


file = open(filename, 'a')
filestuff = file.read(1024)
print filestuff
file.write(filestuff + 'Hello\n')
file.close()


EDIT :
Ohhhhh. Nevermind