Java, .NET, PHP, PYTHON, ANGULAR, .NET, ML, Data Scince, 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))





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