tempfile.TemporaryDirectory
https://docs.python.org/ja/3/library/tempfile.html#tempfile.TemporaryDirectory
code:使用例(コンテキストマネージャでディレクトリ名が取れる).py
# create a temporary directory using the context manager
with tempfile.TemporaryDirectory() as tmpdirname:
print('created temporary directory', tmpdirname)