Last active
July 21, 2022 12:45
-
-
Save XDo0/a6d714cdd18170accf4636b6a4d29f36 to your computer and use it in GitHub Desktop.
python:get files in the directory which includes several subdirectories
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
# Only one-level subfolders are supported | |
import os | |
def get_files(DIR): | |
file_list=list() | |
for sub_dir in os.listdir(DIR): | |
if os.isdir(sub_dir): | |
for file in os.listdir(os.path.join(DIR,sub_dir)): | |
file_list.append(file) | |
return file_list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment