Article From:
os.getcwd() Gets the current working directory, the directory path for the current Python script.Os.chdir ("dirname")  Change the current script working directory; equivalent to shell under CdOs.curdir returns the current directory:'.')
os.pardir  Gets the parent directory string name of the current directory:'..')
os.makedirs('dirname1/dirname2')    Multilayered recursive directories can be generatedOs.removedirs ('dirname1')    If the directory is empty, it is deleted and recursively to the directory at the next level. If it is empty, delete it, and so on.Os.mkdir ('dirname')    Generate single level directory; equivalent to MKDIR dirname in shellOs.rmdir ('dirname')    Delete single level empty directory. If directory is not empty, it can not be deleted and reported wrong. It is equivalent to rmdir dirname in shell.Os.listdir ('dirname')    List all the files and subdirectories under the specified directory, including hidden files, and print them in a list.Os.remove () deletes a fileOs.rename ("oldname","newname")  Rename file /CatalogOs.stat ('path/filename')  Get the file /catalog informationOs.sep outputs the specific path divider of the operating system, under win"\\",LinuxNext to"/"
os.linesep    Output the row terminator used by the current platform, under win"\t\n",LinuxNext to"\n"
os.pathsep    The output string used to split file paths is win; Linux is:The output string indicates the current use of the platform. Win->'nt'; Linux->'posix'
os.system("bash command")  Run the shell command and display it directlyOs.environ gets the system environment variablesOs.path.abspath (path) returns the absolute path of path normalization.Os.path.split (path) makes pathSplit into a directory and a file name of two tuplesOs.path.dirname (path) returns the directory of the path. In fact, it's the first element of os.path.split (path)Os.path.basename (path)Return the final file name of path. How path ends with / / then returns null value. The second elements of os.path.split (path)Os.path.exists (path) if path exists, return to TruE; if path does not exist, return to FalseOs.path.isabs (path) if path is absolute path, return TrueOs.path.isfile (path) if path is an existing file, return T.Rue. Otherwise, return to FalseOs.path.isdir (path) if path is an existing directory, it returns True. Otherwise, return to FalseOs.path.join (path1[, path2[,...After returning multiple paths, the parameters before the first absolute path will be ignored.Os.path.getatime (path) returns the last access time of the file or directory that path refers to.Os.path.getmtime (PATh) returns the last modification time of the file or directory that path refers to.


Link of this Article: os

Leave a Reply

Your email address will not be published. Required fields are marked *