Does the Python “open” function save its content in memory or in a temp file?

后端 未结 6 1526
孤街浪徒
孤街浪徒 2021-01-18 01:42

For the following Python code:

fp = open(\'output.txt\', \'wb\')
# Very big file, writes a lot of lines, n is a very large number
for i in range(1, n):
    f         


        
6条回答
  •  隐瞒了意图╮
    2021-01-18 02:21

    If you write line by line, it should not be a problem. You should show the code of what you are doing before the write. For a start you can try to delete objects where not necessary, use fp.flush() etc..

提交回复
热议问题