The os module provides functions for working with files and directories (“os” stands for “operating system”). os.getcwd returns the name of the current directory:
This module provides a portable way of using operating system dependent functionality.
os.environ module is used to process parameter through which we can access environment variables of our system.
import os output = os.environ['HOME'] print(output)
C:\Users\Python
os.rename function allows programmer to rename the file name.
import os fileDir = "pythonmodule.txt" os.rename(fd,'RenamedName.txt')
os.name function tells the name of the operating system module that it imports. Currently, it registers 'posix', 'nt', 'os2', 'ce', 'java' and 'riscos'.
import os print(os.name)
nt
os.getcwd() function returns the Current Working Directory(CWD) of the file.
import os print(os.getcwd())
C:\Users\Python\Python37-32