OS module in Python provides functions for interacting with the operating system. OS comes under Python’s standard utility modules. This module provides a portable way of using operating system dependent functionality.
os.close() method in Python is used to close the given file descriptor, so that it no longer refers to any file or other resource and may be reused.
A file descriptor is small integer value that corresponds to a file or other input/output resource, such as a pipe or network socket. A File descriptor is an abstract indicator of a resource and act as handle to perform various lower level I/O operations like read, write, send etc.
For Example: Standard input is usually file descriptor with value 0, standard output is usually file descriptor with value 1 and standard error is usually file descriptor with value 2.
Further files opened by the current process will get the value 3, 4, 5 an so on.
fd: A file descriptor, which is to be closed.
Return Type: This method does not return any value
File descriptor closed successfully
- Difference between Method Overloading and Method Overriding in Python
- class method vs static method in Python
- Python | set() method
- Python | next() method
- Python | os.dup() method
- Python | os.utime() method
- Python | sympy.eye() method
- Python | sympy.nP() method
- Python PIL | Image.new() method
- Python PIL | ImagePalette() Method
- Python | Tensorflow exp() method
- Python | os.getgroups() method
- Python | os.getenvb() method
- Python | os.get_exec_path() method
- Python | os.renames() method
- Python | numpy.ma.ids() method
- Python | sympy.ones() method
- Python PIL | BoxBlur() method
- Python | os.getcwdb() method
- Python | os.lseek() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.