OS module, pythonos Module
OS. getcwd () obtains the current working directory, that is, the operating directory path of the current python script. chdir ("dirname") changes the current script working directory, which is equivalent to cdos in shell. curdir returns the current directory :('. ') OS. pardir: Get the string name of the parent directory of the current directory :('.. ') OS. makedirs ('dirname1/dirname2') can generate a multi-layer recursive directory OS. removedirs ('dirname1') if the directory is empty, it is deleted and recursive to the upper-level directory. If the directory is empty, it is deleted and OS is pushed accordingly. mkdir ('dirname') generates a single-level Directory, which is equivalent to mkdir dirnameos in shell. rmdir ('dirname') deletes a single-stage empty directory. If the directory is not empty, it cannot be deleted. An error is returned, which is equivalent to rmdir dirnameos in shell. listdir ('dirname') lists all files and subdirectories in a specified directory, including hidden files and Operating System. remove () deletes a file OS. rename ("oldname", "newname") rename the file/directory OS. stat ('path/filename ') to obtain the file/directory information OS. sep outputs the specific path Separator of the operating system. In win, it is "\", and in Linux it is "/" OS. linesep outputs the line terminator used by the current platform. The line terminator is \ t \ n in win, and the line terminator is \ n in Linux. pathsep outputs the OS string used to split the file path. name output string indicates that the current platform is used. Win-> 'nt '; Linux-> 'posix' OS. system ("bash command") runs the shell command to directly display the OS. environ obtains the OS environment variable. path. abspath (path) returns the absolute path OS of path normalization. path. split (path) splits the path into two groups: Directory and file name, and returns OS. path. dirname (path) returns the path directory. In fact, the first element OS. path. split (path) of OS. path. basename (path) returns the final file name of path. If the path ends with a slash (/) or slash (\), a null value is returned. That is, OS. path. the second element of split (path), OS. path. exists (path) returns True if path exists. Returns Falseos if path does not exist. path. isabs (path) returns Trueos if path is an absolute path. path. isfile (path) returns True if path is an existing file. Otherwise, Falseos. path. isdir (path) is returned. If path is an existing Directory, True is returned. Otherwise, Falseos is returned. path. join (path1 [, path2 [,...]) if multiple paths are combined, the parameters before the first absolute path are ignored. path. getatime (path) returns the last access time OS of the file or directory pointed to by path. path. getmtime (path) returns the last modification time of the file or directory pointed to by path.