【发布时间】:2015-11-05 21:28:14
【问题描述】:
我想将文件位置从当前文件位置更改为另一个位置。假设我当前文件位置是 13,我想将此文件位置更改为 18。
我使用seek() 方法如下,但它显示了一些错误。
代码:-
fileobj = open("intro.txt","r");
content = fileobj.read(13);
pos = fileobj.tell();
print("Current position : ",pos);
fileobj.seek(5,1); #Change position from current position to next five character.
错误
fileobj.seek(5,1);
io.UnsupportedOperation: can't do nonzero cur-relative seeks
我使用 python 3.4.3。我该怎么做?
【问题讨论】:
标签: python python-3.x file-handling