How to delete file?
Emile van Sebille
emile at fenx.com
Sun Jun 2 10:27:49 EDT 2002
"Ken" <ken at hotmail.com> wrote in message
news:add9ai$107clv$1 at ID-49758.news.dfncis.de...
> How do you delete file?
>
import os
os.unlink(path)
os.remove(path)
> If you write to file from beginning position of an existing file, do
you
> overwrite the existing data or insert from it?
>
--or-- to overwrite a file (or create if not already there) just open
it:
>>> print open.__doc__
open(filename[, mode[, buffering]]) -> file object
Open a file. 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. Add a 'b' to the mode for binary files.
Add a '+' to the mode to allow simultaneous reading and writing.
If the buffering argument is given, 0 means unbuffered, 1 means line
buffered, and larger numbers specify the buffer size.
HTH,
--
Emile van Sebille
emile at fenx.com
---------
More information about the Python-list
mailing list