Super Newbie Question
Greg Ewing
greg at cosc.canterbury.ac.nz
Mon Apr 4 21:12:23 EDT 2005
joeyjwc at gmail.com wrote:
> In short, how might I go about deleting just the contents of a file?
File objects have a truncate() method which chops the file
back to zero length (or a length that you specify).
But why not just delete the file? You can always
create another one with the same name later if
you want.
--
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg
More information about the Python-list
mailing list