python IOError: [Errno 0] Error

created at 06-27-2021 views: 3

Under Windows, this exception occurs during the process of opening a file in a+ mode, reading the file, and then writing. The reason is that fflush,fseek, fsetpos, rewind must be performed during the alternate reading and writing process, otherwise python will not know where the current file position is. The most stupid way is to do only one operation of reading or writing before closing the file, so worry-free

One way is to use fseek() or fsetpos() to set the position of the inserted text before writing to the file. [, whence])

Whence is 0, it means that the current file position is at the beginning of the file, 1 means it is after the last read, and 2 means the end of the file. offset is the offset.

To avoid this exception, add,2)
Please log in to leave a comment.