YouTip LogoYouTip

Os Tmpfile

# Python2.x Python os.tmpfile() Method [![Image 3: Python File Methods](#) 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..... [![Image 4: Python File Methods](#) Python OS File/Directory Methods](#)
← Os TtynameOs Tmpfile β†’