mirror of
https://github.com/stardrophere/InsightRadar.git
synced 2026-06-06 00:52:50 +08:00
28 lines
643 B
Python
28 lines
643 B
Python
import os
|
|
|
|
|
|
def print_tree(root, prefix=""):
|
|
items = sorted(
|
|
name for name in os.listdir(root)
|
|
if name != "__pycache__"
|
|
)
|
|
total = len(items)
|
|
|
|
for i, name in enumerate(items):
|
|
path = os.path.join(root, name)
|
|
is_last = (i == total - 1)
|
|
|
|
connector = "└── " if is_last else "├── "
|
|
print(prefix + connector + name)
|
|
|
|
if os.path.isdir(path):
|
|
extension = " " if is_last else "│ "
|
|
print_tree(path, prefix + extension)
|
|
|
|
|
|
root_dir = r"E:\ScnuProject\InsightRadar\backend\app"
|
|
print(os.path.basename(root_dir) + "/")
|
|
print_tree(root_dir)
|
|
|
|
|