OS Module
import os #(operating system)
print(os.getcwd()) #this will show your current working directory(cwd)
#print(dir(os)) #shows all attributes and methods of os
#os.chdir("C://") #to change your current working directory
#print(os.getcwd())
#print(os.listdir("C://")) #this will give all folders and files of this directory
#os.mkdir("harish") #this will make a new folder as harish
#os.makedirs("this/that") #this will make folder as this and in that it will make another folder as that
#os.rename("harish.txt","softwareharish.txt") #this will rename the files
#print(os.path.join("C:/","/harish.txt")) #this will join two directories, in this we no need to take problems of slases(/)
print(os.path.exists("harish.txt")) #this will chek weather the file is exists or not
print(os.path.isfile("harish.txt")) #this will chek weather this is a file or not
print(os.path.isdir("C://")) #this will chek weather this is a directory or not
Comments
Post a Comment