OS Module
import os
# print(dir(os))
# This os.getcwd will get the current working directory's path and will print that
# print(os.getcwd())
# This will change the current directory to th specified in the brackets
# print(os.chdir("C://"))
# print(os.getcwd())
# This will display all the folders and file present at the cwd as a list
# print(os.listdir())
# This will make a new folder in the directory
# os.mkdir("Oho")
# This will make folders inside folder in the directory
# os.makedirs("This/that")
# This will rename a file
# os.rename("aryan1.txt", "aryan2.txt")
# This will give us an environment
# print(os.environ.get('Path'))
# This will join 2 paths and make into 1
# print(os.path.join("C://", "/ Aryan.txt"))
# This will tell whether a directory mentioned existes or not as True Or False
# print(os.path.exists("C://"))
# This will tell whether a directory mentioned existes or not as True Or False
# print(os.path.isdir("C://"))
# This will tell whether a file mentioned existes or not as True Or False
# print(os.path.isfile("aryan.txt"))
Comments
Post a Comment