是的,有一个非常简单的方法来获取它。
导航到项目的根文件夹并从终端运行
tree
。你应该得到这样的东西:
project_root
│ README.md
│
└───some_folder
│ │ another_file.txt
│ │ some_code.code
│ │
│ └───some_subfolder
│ │ some_more_code.txt
│ │ another_file.txt
│ │ a_picture.png
│ │ ...
│
└───another_folder
│ more_files.txt
│ more_code.code
...
现在您可以将此树复制并粘贴到您的自述文件中,用三个反引号 - ``` 括起来以获得 Markdown 样式。
https://ascii-tree-generator.com/ --> 手动 *** 或者 *** powershell 中的树命令 --> auto
对于你的情况我会这样做:
tree -d > my_tree_structure.txt
注意:您可以使用
tree -d -L <level>
限制树的深度。仅对于根目录及其子目录,您将使用 tree -d -L 2
。
我有这个问题很长时间了,我尝试了多种类型的树模块,但没有按照我想要的方式工作,但在这里我为树 dir-tree 制作了一个 python 模型
运行这个:
pip install dir-tree-drh
阅读https://github.com/dragon-devs/dir-tree-drh上的阅读文档。
如果对你有帮助就给个star吧