Python Open()和文件句柄?

我是Python的新手,我已将文件读入内存。然后,我做一个简单的循环来查看文件的内容是...。

然后,我尝试对文件执行其他操作,并且看起来文件已消失或内存不足?

有人可以解释发生了什么,如何将文件存储在内存中以进行查询吗?

>>> fh = open('C:/Python/romeo.txt')
>>> for line in fh:
...     print(line.rstrip())
...
But soft what light through yonder window breaks
It is the east and Juliet is the sun
Arise fair sun and kill the envious moon
Who is already sick and pale with grief
>>> for line in fh:
...     print(line)