python下的tmp路径

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

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

tempfile. tempdir

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 tempdir is unset or None at 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:

  1. The directory named by the TMPDIR environment variable.
  2. The directory named by the TEMP environment variable.
  3. The directory named by the TMP environment variable.
  4. A platform-specific location:
    • On RiscOS, the directory named by the Wimp$ScrapDir environment variable.
    • On Windows, the directories C:\TEMPC:\TMP\TEMP, and \TMP, in that order.
    • On all other platforms, the directories /tmp/var/tmp, and /usr/tmp, in that order.
  5. As a last resort, the current working directory.
tempfile. gettempdir ( )

Return the directory currently selected to create temporary files in. If tempdir is not None, this simply returns its contents; otherwise, the search described above is performed, and the result returned.

New in version 2.3.

tempfile. template

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 by mktemp(). A string of six random letters and digits is appended to the prefix to make the filename unique. The default prefix is tmp.

Older versions of this module used to require that template be set to None after a call to os.fork(); this has not been necessary since version 1.5.2.

tempfile. gettempprefix ( )

Return the filename prefix used to create temporary files. This does not contain the directory component. Using this function is preferred over reading the templatevariable directly.

New in version 1.5.2.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值