Os Tmpfile
# Python2.x Python os.tmpfile() Method
[ Python OS File/Directory Methods](#)
* * *
### Overview
The os.tmpfile() method is used to return an open temporary file object in mode (w+b). This file object has no directory entry and no file descriptor, and will be automatically deleted.
### Syntax
The syntax for the **tmpfile()** method is as follows:
os.tmpfile
### Parameters
* None
### Return Value
Returns a temporary file object.
### Example
The following example demonstrates the use of the tmpfile() method:
#!/usr/bin/python# -*- coding: UTF-8 -*-import os # Create a temporary file object tmpfile = os.tmpfile() tmpfile.write('Temporary file created here.....') tmpfile.seek(0)print tmpfile.read() tmpfile.close
The output of executing the above program is:
Temporary file created here.....
[ Python OS File/Directory Methods](#)
YouTip