How to do virtual file processing?

后端 未结 5 761
滥情空心
滥情空心 2020-11-27 14:15

So for creating files I use the following:

fileHandle = open(\'fileName\', \'w\')

then write the contents to the file, close the file. In t

5条回答
  •  情话喂你
    2020-11-27 14:43

    There is the StringIO module, read its documentation, it should be easy to use.

    Bear in mind, though, that this would keep the "file's" contents in memory. If you have too much data, it would probably be better to create a real file, e.g. in /tmp, and delete it afterwards.

提交回复
热议问题