我在解释器中玩耍,file.write() 方法表现得很奇怪,我希望有人能解释一下。
>>> file.seek(0)
>>> file.tell()
0
>>> file.readline()
'The Project Gutenberg EBook of The Adventures of Sherlock Holmes\n'
>>> file.tell()
65
>>> file.realine()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'file' object has no attribute 'realine'
>>> file.readline()
'by Sir Arthur Conan Doyle\n'
>>> file.tell()
91
>>> file.write("line\n")
>>> file.tell()
4101
>>>
为什么 file.write("line\n") 会跳转到 4101?
文件是这个的副本:http ://norvig.com/big.txt在 r+ 模式下打开