文章内容

2025/5/22 3:16:30,作 者: 黄兵

Windows 打印项目结构

最近在使用 ChatGPT 辅助编程的时候,需要一个项目结构给 ChatGPT,通过查询 ChatGPT,在 Windows 上可以使用 tree 命令打印项目结构。

下面是 Windows 上的 tree 命令详细解释:

/F:列出所有文件

/A:使用 ASCII 字符画树状图(适合输出到文本文件)

tree /F /A > project_structure.txt

当然我们也可以使用 Python 脚本来打印项目结构:

import os

def print_tree(start_path, indent=''):
    for item in os.listdir(start_path):
        full_path = os.path.join(start_path, item)
        print(indent + '|-- ' + item)
        if os.path.isdir(full_path):
            print_tree(full_path, indent + '    ')

print_tree('你的项目路径')

这样就可以实现上面的功能了。

分享到:

发表评论

评论列表