Pliki listy Python w bieżącym katalogu
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
import os
for x in os.listdir():
if x.is_file():
# Prints only text file present in My Folder
print(x)
import os
for root, dirs, files in os.walk("."):
for filename in files:
print(filename)
import os
arr = os.listdir()
print(arr)
>>> ['$RECYCLE.BIN', 'work.txt', '3ebooks.txt', 'documents']