os module provides a very rich way to handle files and directories. Commonly used method in the following table: No. Method and description . 1 os.access (path, MODE) test permission mode 2 the os.chdir (path) to change the current working directory . 3 os.chflags (path, the flags) flag is set to a digital path mark. 4 os.chmod (path, the MODE) Change Permissions 5 os.chown (path, uid, gid) Change the file owner 6 os.chroot (path) Change the root directory of the current process 7 os.close (fd) close the file descriptor fd 8 os.closerange (fd_low, fd_high) closing all file descriptors, from fd_low (included) to fd_high (not included), the error will be ignored 9 os.dup (fd) Duplicate file descriptor fd 10 os.dup2 (fd, FD2) to copy a file descriptor fd into another FD2 . 11 os.fchdir (fd) By changing the current working directory file descriptor 12 os.fchmod (fd, mode) to change the access permissions of a file, the file specified by the parameter fd, parameter mode is file access permissions under Unix. 13 is os.fchown (FD, UID, GID) to change the ownership of a document, this function modifies the user ID and group ID of a file, the file specified by the file descriptor fd. 14 os.fdatasync (fd) forced to write disk files, the file specified by the file descriptor fd, but not mandatory status update file information. 15 os.fdopen (FD [, MODE [, the bufsize of]]) creates a file object file descriptor fd, and returns the file object 16 os.fpathconf (fd, name) Returns an open file system configuration information. value configured for the system name retrieved, it may be a string value defined in the system, many of these names specified in the standard (the POSIX. . 1, the Unix 95, the Unix 98 , and others). . 17 os.fstat (fd) returns a file descriptor fd state, like stat (). 18 is os.fstatvfs (fd) information returned file descriptor fd contains a file system, the Python 3.3 equivalent statvfs (). 19 os.fsync (fd) forces the file descriptor fd file is written to the hard disk. 20 os.ftruncate (fd, length) cut the file descriptor fd corresponding file, so it can not exceed the maximum file size. 21 is The os.getcwd () returns the current working directory 22 is The os.getcwdu () Returns the current working directory is a Unicode objects 23 is os.isatty (fd) If the file descriptor fd is open, while the TTY ( - connected like) device, returns true, otherwise False. 24- os.lchflags (path, flags) mark set the path for the digital mark, similar chflags (), but no soft links 25 os.lchmod (path, the MODE) modify the connection file permissions 26 os.lchown (path, uid, gid) change the file owner, similar chown, but do not follow links. 27 os.link (src, dst) Create a hard link, a parameter named dst, pointing to the parameter src 28 os.listdir (path) returns a list of the name of the file or folder that contains the specified path of the folder. 29 os.lseek (fd, pos, how) setting the file descriptor fd current position pos, how modify: SEEK_SET 0 or calculated from the beginning of the file is provided to pos; SEEK_CUR or 1 from the current position calculation; os.SEEK_END or 2 start from the end of the file. in unix, Windows effective 30 os.lstat (path) like stat (), but no soft links 31 os.major (device) extraction device major number from a raw device number (using the stat the st_dev or st_rdev field). 32 os.makedev (major, minor) to the major and minor device number consisting of a number of Original Equipment 33 is os.makdirs (path [, MODE]) recursively folder creation function. Like mkdir (), but creates all intermediate - Level folder needs to contain subfolders. 34 is os.minor (Device) extract numbers from the original equipment minor device number (using the stat st_dev or st_rdev field). 35 os.mkdir (path [, mode]) to create a named path to the folder mode digital mode. The default mode is0777 (octal). 36 os.mkfifo (path [, mode]) creates a named pipe, mode to digital, the default is 0666 (octal) 37 [ os.mknod (filename [, mode = 0600 , Device]) creates a file called filename system node (file , equipment or special file named pipe). 38 is os.open (File, the flags [, mode]) to open a file and set the desired open options, mode parameter is optional 39 os.openpty () Open a new pseudo-terminal pair. Returns a file descriptor pty and the tty. 40 os.pathconf (path, name) returns the file system-related configuration information. 41 is os.pipe () creates a pipe. Returns a pair of file descriptors (r, w) are read and write 42 is os.popen, (Command [, MODE [, the bufsize of]]) open a pipe from a Command 43 is OS. read (fd, n) Read from the file descriptor fd up to n bytes, returns a string containing bytes read, the file corresponding to the file descriptor fd has reached the end, returns an empty string. 44 os.readlink (path) Returns the soft link points to a file 45 os.remove (path) delete the path for the path of the file. If the path is a folder, will throw OSError; see below rmdir () deletes a directory. 46 os.removedirs (path) recursively delete directories. 47 os.rename (src, DST) rename a file or directory, from src to DST 48 os.renames (Old, new new) recursively rename directory, the file may be renamed. 49 os.rmdir (path) to delete the specified path empty directory, if the directory is not empty, then throw a OSError exception. 50 the os.stat (path) acquired path specified information, functionally equivalent to the stat () system call in the C API. 51 is os.stat_float_times ([newValue]) determines whether time stamp stat_result objects float 52 is os.statvfs (path) Gets the path of the file system statistics 53 os.symlink (src, dst) to create a soft link 54 os.tcgetpgrp (fd) Returns the terminal fd (consisting os.open () return of open file descriptors) associated process group 55 os.tcsetpgrp (FD, PG) process group is provided with a terminal FD (consisting os.open () returns the open file descriptor) is associated pg. 56 os.tempnam ([dir [, prefix]]) A Python 3 has been deleted. Returns a unique pathname for creating temporary files. 57 os.tmpfile () A Python 3 has been deleted. Returns an open mode (W + file object b), which does not file object folder entry, no descriptor will be removed automatically. 58 os.tmpnam () A Python 3 has been deleted. To create a temporary file only a return path 59 os.ttyname (fd) Returns a string that represents the file descriptor fd associated with the terminal device. If fd is not associated with a terminal device, an exception is thrown. 60 os.unlink (path) to delete the file path 61 os.utime (path, Times) Return to access and modify the file path specified time. 62 is os.walk (Top [, the topdown = True [, the onerror = None [, followlinks = False]]]) output file name in a folder in the tree walk by, up or down. 63 is os.write (fd, STR) writes the string into the file descriptor fd. Returns string length actually written 64 the os.path module acquires the attribute information file.