You are here : python_2ososclose

os.close() - os

             

The method close() closes the associated with file descriptor fd.


  • fd -- This is the file descriptor of the file.


Syntax


os.close(fd);


Example


#!/usr/bin/python

import os, sys

# Open a file
fd = os.open( "foo.txt", os.O_RDWR|os.O_CREAT )

# Write one string
os.write(fd, "This is test")

# Close opened file
os.close( fd )

print "Closed the file successfully!!"


Output / Return Value

When we run above program, it produces following result:


Closed the file successfully!!


Limitations


Alternatives / See Also


Reference