本文實例講述了python創建臨時文件夾的方法。分享給大家供大家參考。具體實現方法如下:
1
2
3
4
5
6
|
import tempfile, os tempfd, tempname = tempfile.mkstemp( '.suffix' ) os.write(tempfd, "aString" ) # or, if you want a file-object: os.fdopen(tempfd, 'w+') os.close(tempfd) os.unlink(tempname) |
希望本文所述對大家的Python程序設計有所幫助。