I. Overview of OS Modules
The Python OS module contains common operating system features. For example, copying files, creating files and folders ...
Second, common methods
1, Os.listdir () returns all file and directory names under the specified directory.
2, Os.remove () delete a file.
3, Os.system () run the shell command.
4. The Os.path.split () function returns the directory name and file name of a path
5, Os.path.isfile () and Os.path.isdir () function respectively check whether the given path is a file or directory, the return value is Ture or false
6, Os.path. The exists() function is used to verify that the given path exists and that the return value is Ture or FALSE, respectively.
7, Os.path.getsize (name) get file size, if name is directory return 0L
8. Os.path.splitext () detach file name and extension
9. Os.path.join (path,name) connection directory with file name or directory
10. Os.path.basename (path) returns the file name
11, Os.path.dirname (path) return file path
Python module learning: OS module