Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python os.tmpnam() method

Python os.tmpnam() method

Python File methods Python OS file/directory methods


Overview

The os.tmpnam() method returns a unique path for creating a temporary file.

Syntax

The syntax of the **tmpnam()** method is as follows:


os.tmpnam

Parameters

Return Value

Returns a unique path.

Example

The following example demonstrates the use of the tmpnam() method:


#!/usr/bin/python
# -*- coding: UTF-8 -*-

import os, sys

# Generate temporary path
tmpfn = os.tmpnam()

print "这是一个唯一的路径:"
print tmpfn

The output of the above program is:


This is a unique path:
/tmp/fileUFojpd

Python File methods Python OS file/directory methods