Web | This Site

Python Basics
Python Advanced
Python Useful References
Python Useful Resources
Selected Reading
© 2011 TutorialsPoint.COM

| Home |  | References |  | Discussion Forums |  | About TP

# Python os.close() Method

## Description:

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:

    Closed the file successfully!!

Advertisement

Online Image Processing

Indian Baby Names