相关疑难解决方法(0)

Python 2.7中的tempfile.TemporaryDirectory上下文管理器

有没有办法在Python 2.7的上下文管理器中创建临时目录?

with tempfile.TemporaryDirectory() as temp_dir:
    # modify files in this dir

# here the temporary diretory does not exist any more.
Run Code Online (Sandbox Code Playgroud)

python temp with-statement python-2.7

41
推荐指数
2
解决办法
1万
查看次数

具有自定义名称的临时文件/目录?

如何在python中使用用户定义的名称创建临时文件/目录。我知道tempfile。但是我看不到任何以文件名作为参数的函数。

注意:我需要这个来对包含临时文件的临时目录上的 glob(文件名模式匹配)功能进行单元测试,而不是使用实际的文件系统。

python temporary-files pytest python-unittest

7
推荐指数
2
解决办法
6954
查看次数