f = open("test.json" , "w+")
.....
.....
your code for reading
f.read()
.....
.....
last_position = f.tell() # return current position of file pointer(where you stoped reading)
现在,当您下次读取文件时,请使用seek()函数
f = open("test.json" , "w+")
f.seek(last_position)
f.read() # now this will start reading from last position
使用file的tell()方法(从文件中读取后),这将返回当前指针。 下次阅读时,请使用文件的seek()函数将指针设置为旧位置。你知道吗
示例:
现在,当您下次读取文件时,请使用seek()函数
希望这能有所帮助:)
参见python文档中的linecache
相关问题 更多 >
编程相关推荐