| OS.GETCWD () |
Gets the current working directory, which is the directory path of the current Python script work |
| Os.chdir ("DirName") |
Change the current script working directory, equivalent to the shell CD |
| Os.curdir |
Return to current directory: ('. ') |
| Os.pardir |
Gets the parent directory string name of the current directory: (' ... ') |
| Os.makedirs (' dirname1/dirname2 ') |
Multi-level recursive catalogs can be generated |
| Os.removedirs (' dirname1 ') |
If the directory is empty, it is deleted and recursively to the previous level of the directory, if it is also empty, then delete, and so on |
| Os.mkdir (' dirname ') |
Generate a single-level directory, equivalent to the shell mkdir dirname |
| Os.rmdir (' dirname ') |
Delete 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 under 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 for\n |
| Os.pathsep |
Output a string used to split a file path |
| Os.name |
The output string indicates the current usage platform. Win-> nt ; Linux->posix |
| Os.system ("Bash command") |
Run the shell command to display directly |
| Os.environ |
Get System Environment variables |
| Os.path.abspath (PATH) |
Returns the absolute path normalized by path |
| Os.path.split (PATH) |
Split path into directory and file name two tuples returned |
| Os.path.dirname (PATH) |
Returns the directory of path. is actually the first element of Os.path.split (path) |
| Os.path.basename (PATH) |
Returns the last file name of path. A / \ null value is returned if the path is or ends. 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 |