使用"readlines()";连续两次 [英] Using "readlines()" twice in a row
本文介绍了使用"readlines()";连续两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试执行以下操作:
I'm trying to do something like this:
Lines = file.readlines()
# do something
Lines = file.readlines()
,但是第二次Lines
为空.正常吗?
but the second time Lines
is empty. Is that normal?
推荐答案
您需要使用重置文件指针
You need to reset the file pointer using
file.seek(0)
使用前
file.readlines()
再次
.
这篇关于使用"readlines()";连续两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文