Python os.tmpfile() 方法
python os.tmpfile() 方法
os.tmpfile() 方法用于返回一個打開的模式為(w+b)的臨時文件對象,這文件對象沒有文件夾入口,沒有文件描述符,將會自動刪除。
語法
tmpfile()方法語法格式如下:
os.tmpfile
參數(shù)
- 無
返回值
返回一個臨時文件對象。
實例
以下實例演示了 tmpfile() 方法的使用:
#!/usr/bin/python # -*- coding: utf-8 -*- import os # 創(chuàng)建臨時文件對象 tmpfile = os.tmpfile() tmpfile.write('臨時文件在這創(chuàng)建了.....') tmpfile.seek(0) print tmpfile.read() tmpfile.close
執(zhí)行以上程序輸出結(jié)果為:
臨時文件在這創(chuàng)建了.....
相關(guān)文章
- Python 中文編碼
- Python 基礎(chǔ)語法
- Python while 循環(huán)語句
- Python 循環(huán)嵌套
- Python 正則表達(dá)式
- Python XML 解析
- Python IDE
- Python 鏈表
- Python 圖形
- Python 搜索算法
- Python3 注釋
- Python3 字符串(String)
- Python3 列表(List)
- Python3 集合(Set)
- Python3 if else 語句
- Python3 輸入和輸出
- Python3 面向?qū)ο?/a>
- Python3 命名空間
- Python3 作用域
- Python3 日期和時間