Why can i read lines from file only one time?

后端 未结 4 1582
旧时难觅i
旧时难觅i 2020-12-07 01:42

I have a file containing python\'s object as string, then i open it and doing things like i showing:

>>> file = open(\'gods.txt\')
>>> file         


        
4条回答
  •  离开以前
    2020-12-07 02:43

    There's only one line in that file, and you just read it. readlines returns a list of all the lines. If you want to re-read the file, you have to do file.seek(0)

提交回复
热议问题