Python OS Modules

Python OS Modules

  • The OS module in Python provides a way of using operating system dependent functionality.
  • The functions that the OS module provides allows you to interface with the underlying operating system that Python is running on be that Windows, Mac or Linux. 
  • The OS module in python provides functions for interacting with the operating system. OS, comes under Python’s standard utility modules. This module provides a portable way of using operating system dependent functionality.
  • It is possible to automatically perform many operating system tasks. The OS module in Python provides functions for creating and removing a directory (folder), fetching its contents, changing and identifying the current directory, etc.

Creating Directory

  • We can create a new directory using the mkdir() function from the OS module.  
  • A new directory corresponding to the path in the string argument of the function will be created. If we open D drive in Windows Explorer, we should notice tempdir folder created. 

Some Basic Functions

Code:

  • import os
  • print(dir(os))

 

 

 


 

 

 

Comments