This module generates temporary files and directories. It works on all supported platforms.In version 2.3 of Python, this module was overhauled重写 for enhanced security. It now provides three new functions,NamedTemporaryFile(), mkstemp(), and mkdtemp(…
----需要在程序执行时创建一个临时文件或目录,并希望使用完之后可以自动销毁掉. tempfile 模块中有很多的函数可以完成这任务.为了创建一个匿名的临时文件,可以使用tempfile.TemporaryFile from tempfile import TemporaryFile with TemporaryFile('w+t') as f: # Read/write to the file f.write('Hello World\n') f.write('Testing\n') # Se…