Why can't I call read() twice on an open file?

后端 未结 7 1577
挽巷
挽巷 2020-11-21 05:05

For an exercise I\'m doing, I\'m trying to read the contents of a given file twice using the read() method. Strangely, when I call it the second time, it doesn\

7条回答
  •  清酒与你
    2020-11-21 05:30

    yeah, as above...

    i'll write just an example:

    >>> a = open('file.txt')
    >>> a.read()
    #output
    >>> a.seek(0)
    >>> a.read()
    #same output
    

提交回复
热议问题