在python中使用"临时文件"文件夹

2 python operating-system temporary-files temporary-directory

我最近编写了一个查询PyPI并下载包的脚本; 但是,程序包会下载到用户定义的文件夹中.

如果未指定文件夹,我想以下载文件进入临时文件夹的方式修改脚本.

*nix机器中的临时文件夹是"/ tmp"; 我可以使用任何Python方法找出特定机器中的临时文件夹吗?

如果没有,有人可以建议替代这个问题吗?

Mat*_*all 7

Python有一个内置模块,用于使用临时文件和文件夹.你可能想要tempfile.mkdtemp().