您的位置:首页 > 健康 > 养生 > 东莞企业网站制_网店美工毕业设计论文_百度域名购买_app投放渠道有哪些

东莞企业网站制_网店美工毕业设计论文_百度域名购买_app投放渠道有哪些

2024/10/6 0:34:48 来源:https://blog.csdn.net/m0_73545851/article/details/142518133  浏览:    关键词:东莞企业网站制_网店美工毕业设计论文_百度域名购买_app投放渠道有哪些
东莞企业网站制_网店美工毕业设计论文_百度域名购买_app投放渠道有哪些
import osdef export_directory_structure(folder_path, output_file):with open(output_file, 'w', encoding='utf-8') as file:for root, dirs, files in os.walk(folder_path):# 计算目录的层级,以便用缩进展示目录结构level = root.replace(folder_path, '').count(os.sep)indent = ' ' * 4 * level# 写入目录名称file.write(f'{indent}{os.path.basename(root)}/\n')sub_indent = ' ' * 4 * (level + 1)# 写入文件名称for f in files:file.write(f'{sub_indent}{f}\n')# 使用示例
folder_path = '/path/to/your/folder'  # 替换为你想要导出的目录路径
output_file = 'directory_structure.txt'  # 导出的文本文件名称
export_directory_structure(folder_path, output_file)
print(f"目录结构已导出到 {output_file}")

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com