I. Overview of OS Modules
The Python OS module contains common operating system features.
Second, common methods
1. The Os.name output string indicates the platform being used. If the window is ' NT ', it is ' POSIX ' for Linux/unix users.
2. The OS.GETCWD () function gets the current working directory, which is the directory path of the current Python script work.
3, Os.listdir () returns all file and directory names under the specified directory.
4, Os.remove () delete a file.
5, Os.system () run the shell command.
6. OS.SEP can replace operating system-specific path separators.
7. Os.linesep string gives the line terminator used by the current platform
8. The Os.path.split () function returns the directory name and file name of a path
The 9, Os.path.isfile (), and Os.path.isdir () functions respectively verify that the given path is a file or a directory.
10, Os.path. The Exists() function is used to verify that the given path really exists
11. Os.path.abspath (name): Get absolute path
12, Os.path.normpath (PATH): Canonical path string form
13, Os.path.getsize (name): Get file size, if name is directory return 0L
14, Os.path.splitext (): Detach file name and extension
15, Os.path.join (path,name): Connection directory and file name or directory
16. Os.path.basename (PATH): Return file name
17. Os.path.dirname (PATH): Return file path
Python OS module