1import os
2
3files = os.listdir('.')
4print(files)
5for file in files:
6 # do something
7
1from os import listdir
2from os.path import isfile, join
3onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]
1import os
2#this command will store all .txt files in same directories
3ALL_FILES_IN_DIR = [ELEM for ELEM in os.listdir() if "txt" in ELEM]
4
5#ALL DIRETORIES
6ALL_DIR = [ELEM for ELEM in os.listdir() if "." not in ELEM]
7
1from os import listdir
2from os.path import isfile, join
3onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]
4