“OSError: [Errno 22] Invalid argument” when read()ing a huge file

前端 未结 2 1592
故里飘歌
故里飘歌 2020-12-18 20:37

I\'m trying to write a small script that prints the checksum of a file (using some code from https://gist.github.com/Zireael-N/ed36997fd1a967d78cb2):

import          


        
2条回答
  •  無奈伤痛
    2020-12-18 21:09

    Wow this can be much simpler. Just read the file line by line:

    with open('big-file.txt') as f:
      for i in f:
        print(i)
    

提交回复
热议问题