Last active
December 3, 2019 09:40
-
-
Save anmolj7/60515453f385366d28468615096d59a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
print("Python Program to print list the files in a directory.") | |
Direc = input(r"Enter the path of the folder: ") | |
print(f"Files in the directory: {Direc}") | |
files = os.listdir(Direc) | |
files = [f for f in files if os.path.isfile(Direc+'/'+f)] #Filtering only the files. | |
print(*files, sep="\n") | |
#os.getcwd() gives us the current working directory, and os.listdir lists the director |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment