Memory error due to the huge input file size

后端 未结 2 1982
醉梦人生
醉梦人生 2020-11-29 12:07

When I using the following code to read file:

lines=file(\"data.txt\").read().split(\"\\n\")

I have the following error

Mem         


        
2条回答
  •  广开言路
    2020-11-29 12:46

    use this code to read file line by line:

    for line in open('data.txt'):
        # work with line
    

提交回复
热议问题