Python3 os.tempnam () method
Python3 OS file / directory methods
Outline
os.tempnam () method returns a unique path name is used to create temporary files.
grammar
tempnam () method syntax is as follows:
os.tempnam(dir, prefix)
parameter
dir - path to the temporary file to be created.
prefix - the prefix for temporary files
return value
The method returns a unique path.
Examples
The following example demonstrates tempnam () method of use:
#!/usr/bin/python3 import os, sys # 前缀为 w3big 的文件 tmpfn = os.tempnam('/tmp/w3big,'w3big') print ("这是一个唯一路径:") print (tmpfn)
The above program output is:
这是一个唯一路径: /tmp/w3big/w3bigIbAco8