Python OS module, pythonos
I. OS module Overview
The Python OS module contains common operating system functions.
Ii. Common Methods
1. the OS. name output string indicates the platform in use. If it is a window, it is represented by 'nt '. For Linux/Unix users, it is 'posix '.
2. the OS. getcwd () function obtains the current working directory, that is, the directory path of the current Python script.
3. OS. listdir () returns all files and directory names under the specified directory.
4. OS. remove () deletes an object.
5. Run the shell command in OS. system.
6. OS. sep can replace the path delimiter specified by the operating system.
7. The OS. linesep string indicates the row Terminator used by the current platform.
8. The OS. path. split () function returns the directory name and file name of a path.
9. The OS. path. isfile () and OS. path. isdir () functions verify whether the given path is a file or a directory.
10. OS. path.Exists() The function is used to check whether the given path actually exists.
11. OS. path. abspath (name): Obtain the absolute path.
12. OS. path. normpath (path): standard path string format
13. OS. path. getsize (name): Get the file size. If the name is a directory, return 0L
14. OS. path. splitext (): separates file names and extensions
15. OS. path. join (path, name): Connection directory and file name or directory
16. OS. path. basename (path): returns the file name.
17. OS. path. dirname (path): returns the file path.