Skip to content Skip to sidebar Skip to footer

How To Create A Virtual File For Output?

I need to create a virtual file in memory to trick the system and to let it think that it exists. I have some scientific program and I heed to provide in some function file for out

Solution 1:

The io library can create in-memory file like objects that act like file handles opened with the typical f = open(filename, mode). If you would have opened in normal text mode, a StringIO should do the trick, or if you would have opened the file in binary mode, BytesIO is the way to go.


Post a Comment for "How To Create A Virtual File For Output?"