The OS module is the interaction module between the interpreter and the operating system, using the OS module
#OS module use, as soon as possible to resolve, file additions and deletions to searchImportOSOS.GETCWD ()#gets the current working directory, the path of the current script workOs.chdir ("Path")#change the current script working directory, quite go to CD switch directoryOs.curdir ()#return to current directoryOs.pardir ()#Gets the parent directory string for the current directoryOs.makedirs ("path1/path2")#Multi-level recursive catalogs can be generatedOs.removedirs ("path1")#If the directory is empty then delete, and recursively to the previous layer, if also empty, continue to deleteOs.mkdir ("File_path")#generate a single-level empty directoryOs.listdir ("dirname")#lists all files and subdirectories under the specified directory, including hidden files, displayed as a listOs.remove ("Oldfile","NewFile")#renaming a file/directoryOs.stat ("Path/filename")#get file, directory informationOs.sep ()#output operating system specific path delimiter, solve win under and Liunx '/' and '// 'Os.linesep ()#output for splitting file pathsOs.system ("dir")#Run the shell commandOs.environ ()#Get Environment VariablesOs.path.split (OS.GETCWD ())#Split Environment VariablesOs.path.dirname (__file__) os.path.exists (path)#Returns true if path exists, false if path does not existOs.path.isabs (PATH)#returns True if path is an absolute pathOs.path.isfile (PATH)#returns True if path is a file that exists. Otherwise returns falseOs.path.isdir (PATH)#returns True if path is a directory that exists. Otherwise returns falseOs.path.join (path1[, path2[, ...])#when multiple paths are combined, the parameters before the first absolute path are ignoredOs.path.getatime (PATH)#returns the last access time of the file or directory to which path is pointingOs.path.getmtime (PATH)#returns the last modified time of the file or directory to which path is pointingOs.path.getsize (PATH)#returns the size of path
Python built-in module--os module use