On 01/19/2012 09:32 AM, ADRIAN KELLY wrote:
Hi everyone,
is there an easy way to write to a file (that already exists with data
contained) on a new line. I understand that the file pointer appends where it
left off but how do i write to the next line or even skip a line if possible?
User_info=open("C:\\Documents and Settings\\akelly\\Desktop\\details.txt",'a')
User_info.write("\n".join(Details))
all the best,
Adrian
Presumably this is a text file. By convention, they end with a newline
character. So your data should follow that, and appear on a separate line.
If the file is broken, you can start your data with a \n, just in case.
Or you could do a separate test, to decide if you need it.
If you want a (an extra) blank line between, simply start your data with
a \n .
You can also do this as a separate user_info.write("\n") of course.
--
DaveA
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor