Geeker_odd 发表于 2021-5-4 11:45:03

f.seek()碰到的问题

>>> f.seek(10,1)
Traceback (most recent call last):
File "<pyshell#15>", line 1, in <module>
    f.seek(10,1)
io.UnsupportedOperation: can't do nonzero cur-relative seeks
>>> f.seek(10,2)
Traceback (most recent call last):
File "<pyshell#16>", line 1, in <module>
    f.seek(10,2)
io.UnsupportedOperation: can't do nonzero end-relative seeks

柿子饼同学 发表于 2021-5-4 12:12:12

把完整代码发下

hrp 发表于 2021-5-4 13:01:28

以文本模式打开文件时,seek第二个参数非0时,第一个参数只能是0,以二进制模式打开就没问题。貌似有个说法是文本模式打开的文件只允许从头计算偏移量。

Geeker_odd 发表于 2021-5-4 15:12:45

{:5_110:}谢谢!
页: [1]
查看完整版本: f.seek()碰到的问题