作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
<分区>
我想将文件位置从当前文件位置更改为另一个位置。假设我当前文件位置为 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。我该怎么做?
我是一名优秀的程序员,十分优秀!