Вот у меня есть а:

У меня есть
Код: Выделить всё
c:\desktop\test\A\A.txtКод: Выделить всё
c:\desktop\test\B\B_1\B.txtКод: Выделить всё
c:\desktop\test\123.txt
Вот мой код:
Код: Выделить всё
from pathlib import Path
def searching_all_files(directory: Path):
file_list = [] # A list for storing files existing in directories
for x in directory.iterdir():
if x.is_file():
file_list.append(x)
else:
file_list.append(searching_all_files(directory/x))
return file_list
p = Path('C:\\Users\\akrio\\Desktop\\Test')
print(searching_all_files(p))
Подробнее здесь: https://stackoverflow.com/questions/399 ... -directory
Мобильная версия