How does Python's seek function work?
问题 If I have some file-like object and do the following: F = open('abc', 'r') ... loc = F.tell() F.seek(loc-10) What does seek do? Does is start at the beginning of the file and read loc-10 bytes? Or is it smart enough just to back up 10 bytes? 回答1: It is OS- and libc-specific. the file.seek() operation is delegated to the fseek(3) C call for actual OS-level files. 回答2: According to Python 2.7's docs: file.seek(offset[, whence]) Set the file’s current position, like stdio‘s fseek(). The whence