这几乎与如何解决"OSError:告诉下一个()调用禁用位置"的问题相同.虽然较旧的问题已经收到了一些有用的解决方法的答案,但错误的含义并不清楚.我想知道是否有人可以对此发表评论.
我正在学习Python并且松散地遵循教程.我在Fedora 23上以交互方式输入以下内容:
$ python3
Python 3.4.3 (default, Aug 9 2016, 15:36:17)
[GCC 5.3.1 20160406 (Red Hat 5.3.1-6)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> with open("myfile","r") as file:
... for l in file:
... print("Next line: \"{}\"".format(l))
... print("Current position {:4d}".format(file.tell()))
Run Code Online (Sandbox Code Playgroud)
myfile包含几行文字.输出:
Next line: "This is line number 0
"
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
OSError: telling position disabled by next() call
Run Code Online (Sandbox Code Playgroud)
谷歌搜索此错误会产生惊人的6个结果.在Windows …