How can I create a ramdisk in Python?

后端 未结 4 1085
小鲜肉
小鲜肉 2020-12-05 04:43

I want to create a ramdisk in Python. I want to be able to do this in a cross-platform way, so it\'ll work on Windows XP-to-7, Mac, and Linux. I want to be able to read/writ

4条回答
  •  一整个雨季
    2020-12-05 04:54

    Please read this:

    http://docs.python.org/library/tempfile.html#tempfile.TemporaryFile

    "Return a file-like object that can be used as a temporary storage area. The file is created using mkstemp(). It will be destroyed as soon as it is closed (including an implicit close when the object is garbage collected)."

    It's all handled for you. Do nothing and it already works.

提交回复
热议问题