How to use writelines to append new lines to an existing file
Tom Brown
tom at thebrownboys.net
Thu Sep 22 09:25:32 EDT 2005
On Thursday 22 September 2005 05:52, Nico Grubert wrote:
> Does f = open('/tmp/myfile', 'w') overwrite the existing file or
> does f.writelines('456') replace the first line in the existing file?
Here's an excerpt from open.__doc__
The mode can be 'r', 'w' or 'a' for reading (default),
writing or appending. The file will be created if it doesn't exist
when opened for writing or appending; it will be truncated when
opened for writing.
Tom
More information about the Python-list
mailing list