using python to append a file

Matthew Dixon Cowles matt at mondoinfo.com
Tue Jul 3 15:20:54 EDT 2001


On 3 Jul 2001 12:13:41 -0700, Thanh Le <tle at firstlinux.net> wrote:

>I am new to Python and was wondering if anyone could show me a way to
>append a file (similar to the way Unix does by using >> ). I've tried
>using open('file','r+') method and it overwrote whatever i had in that
>file. I am sure there is a way to append a file, but  havent had much
>luck.

Thanh,
The mode you want is "a" (or "ab"). There's more detail in the
description of the open() function at:

http://www.python.org/doc/current/lib/built-in-funcs.html

Regards,
Matt



More information about the Python-list mailing list