This method closes the associated with file descriptor fd.
Syntax:
os.close(fd);
Parameters:
Here is the detail of parameters:
fd: This is the file descriptor of the file.
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!!"
This would write given content in the foo.txt file and would produce
following result: