os.tmpdir()
以字符串形式返回操作系统默认的临时文件的目录。
¥Returns the operating system's default directory for temporary files as a string.
在 Windows 上,结果可以被 TEMP
和 TMP
环境变量覆盖,并且 TEMP
优先于 TMP
。如果两者都未设置,则默认为 %SystemRoot%\temp
或 %windir%\temp
。
¥On Windows, the result can be overridden by TEMP
and TMP
environment variables, and
TEMP
takes precedence over TMP
. If neither is set, it defaults to %SystemRoot%\temp
or %windir%\temp
.
在非 Windows 平台上,将按所述顺序检查 TMPDIR
、TMP
和 TEMP
环境变量以覆盖此方法的结果。如果两者都未设置,则默认为 /tmp
。
¥On non-Windows platforms, TMPDIR
, TMP
and TEMP
environment variables will be checked
to override the result of this method, in the described order. If none of them is set, it
defaults to /tmp
.
某些操作系统发行版会默认配置 TMPDIR
(非 Windows)或 TEMP
和 TMP
(Windows),而无需系统管理员进行其他配置。os.tmpdir()
的结果通常反映系统偏好,除非用户明确覆盖它。
¥Some operating system distributions would either configure TMPDIR
(non-Windows) or
TEMP
and TMP
(Windows) by default without additional configurations by the system
administrators. The result of os.tmpdir()
typically reflects the system preference
unless it's explicitly overridden by the users.