参考文章:https://www.pianshen.com/article/8682278869/
非常感谢
import os
import os.path
def dfs_showdir(path, depth):
if depth == 0:
print("root:[" + path + "]")
for item in os.listdir(path):
if '.git' not in item:
print("| " * depth + "|--" + item)
newitem = path + '/' + item
if os.path.isdir(newitem):
dfs_showdir(newitem, depth + 1)
if __name__ == '__main__':
dfs_showdir('D:\MyLearning\PyCharm\myQt01', 0) # 这里输入需要导出目录结构的根路径**加粗样式**