The OS module of the Python-based module
The role of the OS module:
OS, the semantics of the operating system, so it must be operating system-related functions, can handle files and directories we need to do daily manual operations, such as: Display the current directory of all files/delete a file/get file Size ...
In addition, the OS module is not limited by the platform, that is to say: when we want to display the current command in Linux to use the PWD command, and the Windows CMD command line will use this, the amount ... I wipe, I really do not know, (no matter what, certainly not pwd), this time we use the Python OS module Os.path.abspath (name) feature, no matter whether Linux or Windows can get the current absolute path.
Common features of the OS module:
1 Os.name #显示当前使用的平台
>>> os.name ' nt ' #这表示Windows >>> os.name ' POSIX ' #这表示Linux
2 OS.GETCWD () #显示当前python脚本工作路径
>>> os.getcwd () ' c:\\users\\capital-d\\pycharmprojects\\untitled ' #使用pycharm >>> os.getcwd () '/ Root ' #Linux平台在/root directory directly using the Python3 command
The OS module of the Python-based module