Файлы списка Python в текущем каталоге
import os
files = os.listdir('.')
print(files)
for file in files:
# do something
Soggy Boi
import os
files = os.listdir('.')
print(files)
for file in files:
# do something
import os
print(os.listdir('/path/to/folder/to/list'))
from os import listdir
from os.path import isfile, join
onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]
import os
def fn(): # 1.Get file names from directory
file_list=os.listdir(r"C:\Users")
print (file_list)
#2.To rename files
fn()
import os
#this command will store all .txt files in same directories
ALL_FILES_IN_DIR = [ELEM for ELEM in os.listdir() if "txt" in ELEM]
#ALL DIRETORIES
ALL_DIR = [ELEM for ELEM in os.listdir() if "." not in ELEM]
lstJson = [f for f in os.listdir(str(self.pathJson)) if f.endswith('.json')]
return lstJson