Python os.tmpnam() method
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
-
None
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