跳转到主要内容

程序退出时删除临时文件,tempfile和atexit的结合应尽可能简单。

项目描述

tempfileatexit

Python库,用于程序结束时删除临时文件和目录。

安装

pip install tempfileatexit

用法

自动方式

import tempfileatexit as tfae
(fs, my_tempfile) = tfae.mkstemp()
my_tempdir = tfae.mkdtemp()

print(tempfileatexit.list(verbose=True))

手动方式

import tempfileatexit
import tempfile

(fs, my_tempfile) = tempfile.mkstemp()
my_tempdir = tempfile.mkdtemp()

tempfileatexit.register(my_tempfile)
tempfileatexit.register(my_tempdir)


print(tempfileatexit.list(verbose=True))

运行代码后程序存在,my_tempfilemy_tempdir将会消失。

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

tempfileatexit-0.0.3.tar.gz (2.1 kB 查看哈希值)

上传时间:

构建分布

tempfileatexit-0.0.3-py3-none-any.whl (3.2 kB 查看哈希值)

上传时间: Python 3

由以下组织支持