28.10.2021 Views

Python Tutorial ( PDFDrive )

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Line No 4 - This is 5th line

Line No 5 - This is 6th line

Line No 6 - This is 7th line

OS Object Methods

The os module provides a big range of useful methods to manipulate files and directories. Most of the useful

methods are listed here:

SN Methods with Description

1

2

3

4

5

6

7

8

9

10

11

12

13

os.access(path, mode)

Use the real uid/gid to test for access to path.

os.chdir(path)

Change the current working directory to path

os.chflags(path, flags)

Set the flags of path to the numeric flags.

os.chmod(path, mode)

Change the mode of path to the numeric mode.

os.chown(path, uid, gid)

Change the owner and group id of path to the numeric uid and gid.

os.chroot(path)

Change the root directory of the current process to path.

os.close(fd)

Close file descriptor fd.

os.closerange(fd_low, fd_high)

Close all file descriptors from fd_low (inclusive) to fd_high (exclusive), ignoring errors.

os.dup(fd)

Return a duplicate of file descriptor fd.

os.dup2(fd, fd2)

Duplicate file descriptor fd to fd2, closing the latter first if necessary.

os.fchdir(fd)

Change the current working directory to the directory represented by the file descriptor fd.

os.fchmod(fd, mode)

Change the mode of the file given by fd to the numeric mode.

os.fchown(fd, uid, gid)

Change the owner and group id of the file given by fd to the numeric uid and gid.

TUTORIALS POINT

Simply Easy Learning

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!