import os def list_directory_structure(startpath): for root, dirs, files in os.walk(startpath): level = root.replace(startpath, '').count(os.sep) indent = ' ' * 4 * level print(f"{indent}{os.path.basename(root)}/") subindent = ' ' * 4 * (level + 1) for f in files: if not f.endswith(('.png', '.jpg')): print(f"{subindent}{f}") # 指定需要列出目录结构的根目录路径 root_path = '/mnt/petrelfs/zhuchenglin/LLaVA' # 例如 '/home/user/my_directory' list_directory_structure(root_path)