python 读取文件时记录读取的最后一行,下次读取时从最后一行开始读取
1个回答
展开全部
fp = open("file")
for i, line in enumerate(fp):
if i == 25: # 26th line
elif i == 29: # 30th line
elif i > 29:
break
fp.close()
或者:
import linecache
file=open('3_2.txt','r')
linecount=len(file.readlines())
linecache.getline('3_2.txt',linecount)
for i, line in enumerate(fp):
if i == 25: # 26th line
elif i == 29: # 30th line
elif i > 29:
break
fp.close()
或者:
import linecache
file=open('3_2.txt','r')
linecount=len(file.readlines())
linecache.getline('3_2.txt',linecount)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询