출처:http://docs.python.org/2/library/tempfile.html

tempfile.mkdtemp([suffix=''[, prefix='tmp'[, dir=None]]])

Creates a temporary directory in the most secure manner possible. There are no race conditions in the directory’s creation. The directory is readable, writable, and searchable only by the creating user ID.

The user of mkdtemp() is responsible for deleting the temporary directory and its contents when done with it.

The prefix, suffix, and dir arguments are the same as for mkstemp().

mkdtemp() returns the absolute pathname of the new directory.

New in version 2.3.


tempfile.NamedTemporaryFile([mode='w+b'[, bufsize=-1[, suffix=''[, prefix='tmp'[, dir=None[, delete=True]]]]]])

This function operates exactly as TemporaryFile() does, except that the file is guaranteed to have a visible name in the file system (on Unix, the directory entry is not unlinked). That name can be retrieved from the name attribute of the file object. Whether the name can be used to open the file a second time, while the named temporary file is still open, varies across platforms (it can be so used on Unix; it cannot on Windows NT or later). If delete is true (the default), the file is deleted as soon as it is closed.

The returned object is always a file-like object whose file attribute is the underlying true file object. This file-like object can be used in a with statement, just like a normal file.

New in version 2.3.

New in version 2.6: The delete parameter.


'리눅스 > 스크립트/유틸' 카테고리의 다른 글

[파이썬] String 가지고 놀기  (0) 2013.06.04
python, regular expression match  (0) 2013.04.28
python, getopt  (0) 2013.04.21
python, pass statement  (0) 2013.04.17
git 저장소 추가 시에 주의 할 점.  (0) 2013.03.24
Posted by code cat