有没有办法在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中使用用户定义的名称创建临时文件/目录。我知道tempfile。但是我看不到任何以文件名作为参数的函数。
注意:我需要这个来对包含临时文件的临时目录上的 glob(文件名模式匹配)功能进行单元测试,而不是使用实际的文件系统。