Python method tmpfile() returns a new temporary file object opened in update mode (w+b). The file has no directory entries associated with it and will be deleted automatically once there are no file descriptors.
The Python os.tmpfile() method has been deprecated.Syntax
Following is the syntax for Python os.tmpfile() method −
os.tmpfile()Parameters
The Python os.tmpfile() method does not accept any parameters.
Return ValueThe Python os.tmpfile() method returns a new temporary file object
ExampleThe following example shows the usage of tmpfile() method.
import os # The file has no directory entries associated with it and will be # deleted automatically once there are no file descriptors. tmpfile = os.tmpfile() tmpfile.write('Temporary newfile is here.....') tmpfile.seek(0) print (tmpfile.read()) tmpfile.close
When we run above program, it produces following result −
Temporary newfile is here.....
python_files_io.htm
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4