Python os.tempnam() 方法
Python 教程
· 2019-02-04 12:44:50
概述
os.tempnam() 方法用于返回唯一的路径名用于创建临时文件。
语法
tempnam()方法语法格式如下:
os.tempnam(dir, prefix)
参数
dir -- 要创建的临时文件路径。
prefix -- 临时文件前缀
返回值
该方法返回唯一路径。
实例
以下实例演示了 tempnam() 方法的使用:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import os, sys
# 前缀为 codercto 的文件
tmpfn = os.tempnam('/tmp/codercto,'codercto')
print "这是一个唯一路径:"
print tmpfn
执行以上程序输出结果为:
这是一个唯一路径: /tmp/codercto/coderctoIbAco8
点击查看所有 Python 教程 文章: https://www.codercto.com/courses/l/8.html
Rapid Web Applications with TurboGears
Mark Ramm、Kevin Dangoor、Gigi Sayfan / Prentice Hall PTR / 2006-11-07 / USD 44.99
"Dear PHP, It's over between us. You can keep the kitchen sink, but I want my MVC. With TurboGears, I was able to shed the most heinous FileMaker Pro legacy 'solu-tion' imaginable. It has relationshi......一起来看看 《Rapid Web Applications with TurboGears》 这本书的介绍吧!