-
When set to a value other than
None, this variable defines the default value for the dir argument to all the functions defined in this module.If
tempdiris unset orNoneat any call to any of the above functions, Python searches a standard list of directories and sets tempdir to the first one which the calling user can create files in. The list is:- The directory named by the
TMPDIRenvironment variable. - The directory named by the
TEMPenvironment variable. - The directory named by the
TMPenvironment variable. - A platform-specific location:
- On RiscOS, the directory named by the
Wimp$ScrapDirenvironment variable. - On Windows, the directories
C:\TEMP,C:\TMP,\TEMP, and\TMP, in that order. - On all other platforms, the directories
/tmp,/var/tmp, and/usr/tmp, in that order.
- On RiscOS, the directory named by the
- As a last resort, the current working directory.
- The directory named by the
tempfile.
tempdir
-
Return the directory currently selected to create temporary files in. If
tempdiris notNone, this simply returns its contents; otherwise, the search described above is performed, and the result returned.New in version 2.3.
tempfile.
gettempdir
(
)
-
Deprecated since version 2.0: Use
gettempprefix()instead.When set to a value other than
None, this variable defines the prefix of the final component of the filenames returned bymktemp(). A string of six random letters and digits is appended to the prefix to make the filename unique. The default prefix istmp.Older versions of this module used to require that
templatebe set toNoneafter a call toos.fork(); this has not been necessary since version 1.5.2.
tempfile.
template

当环境变量未设置或为空时,Python会在一系列标准目录中寻找,包括环境变量指定的目录,以及平台特定的位置如Windows的TEMP目录,来创建默认的临时文件夹。若所有尝试都失败,则使用当前工作目录。
1368

被折叠的 条评论
为什么被折叠?



