os module description: The python os module contains common operating system functions
os.access(path, mode) # Check permission mode
os.chdir(path) # Change the current working directory
os.chflags(path, flags) # Set the path flag to a digital flag.
os.chmod(path, mode) # Change permissions
os.chown(path, uid, gid) # Change file owner
os.chroot(path) # Change the root directory of the current process
os.close(fd) # Close the file descriptor fd
os.closerange(fd_low, fd_high) # Close all file descriptors from fd_low (inclusive) to fd_high (exclusive), errors will be ignored
os.curdir # Return to the current directory: ('.')
os.dup(fd) # Copy file descriptor fd
os.dup2(fd, fd2) # Copy one file descriptor fd to another fd2
os.environ # Get system environment variables
os.fchdir(fd) # Change the current working directory through the file descriptor
os.fchmod(fd, mode) # Change the access permissions of a file. The file is specified by the parameter fd. The parameter mode is the file access permissions under Unix.
os.fchown(fd, uid, gid) # Modify the ownership of a file. This function modifies the user ID and user group ID of a file specified by the file descriptor fd.
os.fdatasync(fd) # Force the file to be written to the disk. The file is specified by the file descriptor fd, but does not force the status information of the file to be updated.
os.fdopen(fd[, mode[, bufsize]]) # Create a file object through file descriptor fd and return this file object
os.fpathconf(fd, name) # Return the system configuration information of an open file . name is the value of the system configuration being retrieved, which may be a string that defines a system value. These names are specified in many standards (POSIX.1, Unix 95, Unix 98, and others).
os.fstat(fd) # Return the status of file descriptor fd, like stat().
os.fstatvfs(fd) # Returns the file system information of the file containing file descriptor fd, like statvfs()
os.fsync(fd) # Forces the file with file descriptor fd to be written to the hard disk.
os.ftruncate(fd, length) # Crop the file corresponding to the file descriptor fd, so it cannot exceed the maximum file size.
os.getcwd() # Returns the current working directory
os.getcwdu() # Returns a Unicode object of the current working directory
os.isatty(fd) # If the file descriptor fd is open and tty(-like) If the device is connected, it returns true, otherwise False.
os.lchflags(path, flags) # Set the path flag to a digital flag, similar to chflags(), but without a soft link
os.lchmod(path, mode) # Modify the connection file permissions
os.lchown(path, uid, gid) # Change the file owner, similar to chown, but does not follow the link.
os.link(src, dst) # Create a hard link named parameter dst, pointing to parameter src
os.listdir(path) # Return a list of the names of files or folders contained in the folder specified by path.
os.lseek(fd, pos, how) # Set the current position of the file descriptor fd to pos, modify it in how: SEEK_SET or 0 sets the pos calculated from the beginning of the file; SEEK_CUR or 1 calculates from the current position; os.SEEK_END Or 2 starts from the end of the file. Valid in unix and Windows
os.lstat(path) # Like stat(), but without soft links
os.linesep # The line terminator used by the current platform, under win it is "tn" , "n" under Linux
os.major(device) # Extract the device major number from the original device number (use st_dev or st_rdev field in stat).
os.makedev(major, minor) # Use the major and minor device numbers to form an original device number
os.makedirs(path[, mode]) # Recursive folder creation function. Like mkdir(), but all intermediate-level folders created need to contain subfolders.
os.minor(device) # Extract the device minor number from the original device number (use st_dev or st_rdev field in stat).
os.mkdir(path[, mode]) # Create a folder named path with the mode of numeric mode. The default mode is 0777 (octal).
os.mkfifo(path[, mode]) # Create a named pipe, mode is a number, the default is 0666 (octal)
os.mknod(filename[, mode=0600, device]) # Create a file system node named filename (file, device special file or named pipe).
os.open(file, flags[, mode]) # Open a file and set the required opening options. The mode parameter is optional.
os.openpty() # Open a new pseudo-terminal pair. Returns the file descriptors for pty and tty.
os.pathconf(path, name) # Return the system configuration information of related files.
os.pathsep # String used to split file paths
os.pardir # Get the parent directory string name of the current directory: ('..')
os.pipe() # Create a pipe. Return a pair of file descriptions Symbols (r, w) are for reading and writing respectively
os.popen(command[, mode[, bufsize]]) # Open a pipe from a command
os.path.abspath(path) # Return the normalized absolute path of path
os.path.split(path) # Split path into directory and file name tuples and return
os.path.dirname(path) # Return the directory of path. In fact, it is the first element of os.path.split(path)
os.path.basename(path) # Returns the last file name of path. If path ends with / or, a null value will be returned. That is, the second element of os.path.split(path)
os.path.exists(path) # If path exists, return True; if path does not exist, return False
os.path.isabs(path) # If path Is an absolute path, returns True
os.path.isfile(path) # If path is an existing file, return True. Otherwise, return False
os.path.isdir(path) # If path is an existing directory, return True. Otherwise return False
os.path.join(path1[, path2[, ...]]) # Return after combining multiple paths. Parameters before the first absolute path will be ignored
os.path.getatime(path ) # Return the last access time of the file or directory pointed to by path
os.path.getmtime(path) # Return the last modification time of the file or directory pointed by path
os.name # A string indicating the current platform. win->'nt'; Linux->'posix'
os.read(fd, n) # Read up to n bytes from the file descriptor fd and return a string containing the read bytes, file descriptor The file corresponding to fd has reached the end, and an empty string is returned.
os.readlink(path) # Return the file pointed to by the soft link
os.remove(path) # Delete the file with path. If path is a folder, OSError will be thrown; see rmdir() below to delete a directory.
os.removedirs(path) # Recursively delete directories. If the directory is empty, delete it and recurse to the upper-level directory. If it is also empty, delete it and so on.
os.rename(src, dst) # Rename the file or directory from src to dst
os. renames(old, new) #Recursively rename directories and files.
os.rmdir(path) # Delete the empty directory specified by path. If the directory is not empty, throw an OSError exception.
os.sep # Operating system-specific path separator, "\" under win, "/" under Linux
os.stat(path) # Get information about the path specified by path, the function is equivalent to stat in the C API () system call.
os.stat_float_times([newvalue]) #Determine whether stat_result displays timestamps as float objects
os.statvfs(path) #Get file system statistics of the specified path
os.symlink(src, dst) #Create a soft link
os.system("bash command") # Run the shell command and display directly
os.tcgetpgrp(fd) # Return the process group associated with the terminal fd (an open file descriptor returned by os.open())
os .tcsetpgrp(fd, pg) # Set the process group associated with terminal fd (an open file descriptor returned by os.open()) to pg.
os.tempnam([dir[, prefix]]) # Return the unique pathname used to create temporary files.
os.tmpfile() # Returns a file object with the open mode (w+b). This file object has no folder entry or file descriptor and will be automatically deleted.
os.tmpnam() # Returns a unique path for creating a temporary file
os.ttyname(fd) # Returns a string representing the terminal device associated with file descriptor fd. If fd is not associated with the terminal device, an exception is raised.
os.unlink(path) # Delete the file path
os.utime(path, times) # Return the access and modification time of the specified path file.
os.walk(top[, topdown=True[, onerror=None[, followlinks=False]]]) # Output the file names in the folder by walking in the tree, up or down.
os.write(fd, str) # Write a string to the file descriptor fd. Return the actual written string length