我的Python解释器(v2.6.5)在以下代码段中引发了上述错误:
fd = open("some_filename", "r")
fd.seek(-2, os.SEEK_END) #same happens if you exchange the second arg. w/ 2
data=fd.read(2);
最后一次调用是 fd.seek()
Traceback (most recent call last):
File "bot.py", line 250, in <module>
fd.seek(iterator, os.SEEK_END);
IOError: [Errno 22] Invalid argument
这件奇怪的事情在于,异常仅在执行整个代码时发生,而不是仅在打开文件的特定部分。 在这段代码运行时,已经打开的文件肯定存在,磁盘也没有满,变量“iterator”的值与第一个代码块中一样正确。 我的错误可能是什么呢? 提前感谢。