Get The Most Affordable Hosting in the World!
Starting at just $1.87/month, Vercaa offers unbeatable pricing for world-class web hosting services.
Fast, reliable, and secure hosting to power your website without breaking the bank. Plus, enjoy a free CDN for faster loading times worldwide!
Get Started Now!The os module provides a big range of useful methods to manipulate files. Most of the useful methods are listed here −
Sr.No. | Methods with Description |
---|---|
1 |
os.close(fd) Close file descriptor fd. |
2 |
os.closerange(fd_low, fd_high) Close all file descriptors from fd_low (inclusive) to fd_high (exclusive), ignoring errors. |
3 |
Return a duplicate of file descriptor fd. |
4 |
Force write of file with filedescriptor fd to disk. |
5 |
os.fdopen(fd[, mode[, bufsize]]) Return an open file object connected to the file descriptor fd. |
6 |
Force write of file with filedescriptor fd to disk. |
7 |
Truncate the file corresponding to file descriptor fd, so that it is at most length bytes in size. |
8 |
Set the current position of file descriptor fd to position pos, modified by how. |
9 |
Open the file file and set various flags according to flags and possibly its mode according to mode. |
10 |
Read at most n bytes from file descriptor fd. Return a string containing the bytes read. If the end of the file referred to by fd has been reached, an empty string is returned. |
11 |
os.tmpfile() Return a new file object opened in update mode (w+b). |
12 |
Write the string str to file descriptor fd. Return the number of bytes actually written. |