我的 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
奇怪的是,异常仅在执行我的整个代码时发生,而不是仅在打开文件的特定部分时发生。在这部分代码的运行时,打开的文件肯定存在,磁盘未满,变量“迭代器”包含一个正确的值,如第一个代码块。我的错误可能是什么?
提前致谢