Python has inbuilt os and glob module that provides function like os.walk(), os.listdir(), blob.blob() method that list directories and subdirectories.
Python has an OS module that provides the functions to deal with file management. We can list files in directory and subdirectory programmatically in Python using the OS module. In this article, we will discuss the different methods to generate a list of all files in the directory tree.
Let’s print the whole files listed in our current working directory.
First, you need to import the os module in your file and then use the os.listdir() function.
Write the following code inside the *app.py *file.
## app.py
import os
print(os.listdir(path='.'))
The OS module is a python module that provides the interface for interacting with the underlying operating system that Python is running.
Python modules are files containing the set of functions you want to include in your app. Create a module and import that module in your file.
Today you're going to learn how to use Python programming in a way that can ultimately save a lot of space on your drive by removing all the duplicates. We gonna use Python OS remove( ) method to remove the duplicates on our drive. Well, that's simple you just call remove ( ) with a parameter of the name of the file you wanna remove done.
In this tutorial, you’re going to learn a variety of Python tricks that you can use to write your Python code in a more readable and efficient way like a pro.
In this tutorial, we'll learn about OS Module and how can you use it in variety of operating system related tasks using it’s methods