為什么我的偏移量不能為負數(shù)?
>>> f.tell()
10
>>> f.seek(-5, os.SEEK_CUR)
Traceback (most recent call last):
? File "<pyshell#57>", line 1, in <module>
? ? f.seek(-5, os.SEEK_CUR)
io.UnsupportedOperation: can't do nonzero cur-relative seeks
>>> f.tell()
10
>>> f.seek(-5, os.SEEK_CUR)
Traceback (most recent call last):
? File "<pyshell#57>", line 1, in <module>
? ? f.seek(-5, os.SEEK_CUR)
io.UnsupportedOperation: can't do nonzero cur-relative seeks
2017-01-18
舉報
2019-01-16
open('imoc.txt','rb+')?
2017-02-05
你用的是 python3嗎?
我試了一下,用Python3就會出現(xiàn) can't do nonzero cur-relative seeks 的問題
用Python2就沒事了
2017-01-20
?在文本文件中,沒有使用b模式選項打開的文件,只允許從文件頭開始計算相對位置,從文件其他位置計算時就會引發(fā)異常。