Course Content

If you are facing any issue in playing video please use Firefox browser.

Course Content

Description

What is the Directory in Python

 

In this lecture we will see that,

How to display list of items from directory ?

How to implement other functions like getcwd(), remove() ?

 

'os' module : This is used when you want to move images from one folder to another and give their your own name, and if you have too much files in your any project and you want to store that in your required ID than you can this.

 

To see directory :

import os

path='C:\\Users\\Admin\\Desktop'

print(os.listdir(path))

 

To change the name of a file from any directory :

import os

path='C:\\Users\\Admin\\Desktop'

print(os.listdir(path))

os.renames(C:\\Users\\Admin\\Desktop\\Alpha.txt,C:\\Users\\Admin\\Desktop\\Alpha123.txt)

print(os.listdir(path))

 

Implementation of getcwd() :

import os

print(os.getcwd())

O/P :

D:\PythonWorkspace\FileName\scr

 

Implementation of remove() :

import os

path='C:\\Users\\Admin\\Desktop\\newdir\\Alpha123.txt'

os.remove(path)

FAQs

Share With Friend

Have a friend to whom you would want to share this course?

Download The Apps

Code Scan or Download the app
Google Play Store
297K+ Downloads
4.5 Rating
10K+ Reviews
  • Learn anywhere on the go
  • Get regular updates about your enrolled or new courses
  • Share content with your friends
  • Evaluate your progress through practice tests
  • No internet connection needed
  • Enroll for the webinar and join at the time of the webinar from anywhere