DEV Community

loading...
Cover image for Complete Guide for OS Module in Python Every Developer should know

Complete Guide for OS Module in Python Every Developer should know

expoashish profile image Ashish Yadav ・1 min read

Introduction to Python OS Module: The OS module in Python provides functions for interacting with the operating system. It offers many useful OS functions that are used to perform OS-based tasks and get related information about operating system. The OS comes under Python's standard utility modules. Lets Start:-

To work with the OS module, we need to import the OS module:

import os
Enter fullscreen mode Exit fullscreen mode



  1. os.name:

This function gives the name of the operating system dependent module imported. The following names have currently been registered: ‘posix’, ‘nt’, ‘os2’, ‘ce’, ‘java’ and ‘riscos’

Code:

import os
print(os.name)
Enter fullscreen mode Exit fullscreen mode



  1. os.mkdir() :

This function is used to create new directory.

Code:

import os
print(os.mkdir(path))
Enter fullscreen mode Exit fullscreen mode




For Continue Reading->

🎥💡🔥AND Subscribe to Our YouTube Channel bestcodecreator

🎥💡🔥AND Support Our Blogging site myblogs

Conclusion:

Thank you for reading this blog. I wish you the best in your journey in learning and mastering in Python Programming🔥🔥.

Discussion (0)

pic
Editor guide