python下的tmp路径

时间:2022-11-25 20:24:58
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.