How to delete only the content of file in python
How to delete only the content of file in python There are several ways of setting the logical size of a file to 0, depending how you access that file: To empty an open file: def deleteContent(pfile): pfile.seek(0) pfile.truncate() To empty an open file whose file descriptor is known: def deleteContent(fd): os.ftruncate(fd, 0) os.lseek(fd, 0, … Read more