tempfile.TemporaryDirectory()

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.

doc_python
2016-10-07 17:44:20
Comments
Leave a Comment

Please login to continue.