#!/usr/bin/env python__author__="lrtao2010" #python3.7 OS module#an OS module is an interface that interacts with the operating system#OS.GETCWD () Gets the current working directory, which is the directory path of the current Python script work#Os.chdir ("dirname") changes the current script working directory, equivalent to the shell CD#Os.curdir Returns the current directory: ('. ')#Os.pardir Gets the parent directory string name of the current directory: (' ... ')#os.makedirs (' dirname1/dirname2 ') can generate multi-level recursive directories#os.removedirs (' dirname1 ') if the directory is empty, then delete, and recursively to the previous level of the directory, if also empty, then delete, and so on#os.mkdir (' dirname ') generates a single-level directory, equivalent to mkdir dirname in the shell#os.rmdir (' dirname ') delete the single-level empty directory, if the directory is not empty can not be deleted, error, equivalent to the shell rmdir dirname#os.listdir (' dirname ') lists all files and subdirectories in the specified directory, including hidden files, and prints as a list#os.remove () delete a file#os.rename ("Oldname", "newname") renaming files/directories#os.stat (' path/filename ') get File/directory information#OS.SEP output operating system-specific path delimiter, win under "\ \", Linux for "/"#os.linesep Output The line terminator used by the current platform, win under "\t\n", Linux "\ n"#os.pathsep output is used to split the file path of the string win down for;, Linux for:#The os.name output string indicates the current usage platform. Win-> ' NT '; Linux-> ' POSIX '#os.system ("Bash command") runs a shell command that directly displays#Os.environ getting system environment variables#Os.path.abspath (path) returns the absolute path normalized by path#os.path.split (path) splits path into directory and file name two tuples returned#os.path.dirname (path) returns the previous level of directory on path. is actually the first element of Os.path.split (path)#os.path.basename (path) returns the last file name of path. If path ends with a/or \, then a null value is returned. The second element of Os.path.split (path)#os.path.exists (path) returns true if path exists, false if path does not exist#os.path.isabs (path) returns True if path is an absolute path#os.path.isfile (path) returns True if path is a file that exists. Otherwise returns false#os.path.isdir (path) returns True if path is a directory that exists. Otherwise returns false#Os.path.join (path1[, path2[, ...]) When multiple paths are combined, the parameters before the first absolute path are ignored#os.path.getatime (path) returns the last access time of the file or directory to which path is pointing#os.path.getmtime (path) returns the last modified time of the file or directory to which path is pointing#Import OS#print (OS.GETCWD ())#E:\python\learning\app\Module_and_Functions#print (os.name)## NT
python3.7 OS Module