Java, .NET, PHP, PYTHON, ANGULAR, ML, Data Science, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

OS Module in Python:- 


 It is used to perform the operation in a file under an operating system such as create a directory, change directory, remove directory, rename the file, delete the file, etc.



complete program explanation:-



import os
#os.mkdir("hello")
os.chdir("hello")
#os.mkdir("hello1")
f=open("hello1.txt","w")
f.write("hello world")
f.close()
os.remove("hello1.txt")
#os.rmdir("hello1")
print(os.getcwd())
#print(os.listdir("c:"))
print(os.listdir())
location = 'd:/c/'
for file in os.listdir(location):
   # if file.endswith(".c"):
        print(os.path.join(location, file))



Assignment of os module:-

1)  WAP to count total folder in the computer, drive, max size folder, total image for the particular director, total video on the directory, total python program in the computer.






1 Comments

If you have any doubt in programming or join online classes then you can contact us by comment .

  1. Q:- WAP to count total folder in the drive ?
    Solution: -
    import os
    print("The Total Number of Folder's are available in Given Path are : -")
    print(len(os.listdir('C:/')))

    ReplyDelete

Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post