tempfile.TemporaryDirectory(suffix=None, prefix=None, dir=None)
This function securely creates a temporary directory using the same rules as mkdtemp()
. The resulting object can be used as a context manager (see Examples). On completion of the context or destruction of the temporary directory object the newly created temporary directory and all its contents are removed from the filesystem.
The directory name can be retrieved from the name
attribute of the returned object. When the returned object is used as a context manager, the name
will be assigned to the target of the as
clause in the with
statement, if there is one.
The directory can be explicitly cleaned up by calling the cleanup()
method.
New in version 3.2.
Please login to continue.