-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtree_print.py
More file actions
executable file
·34 lines (28 loc) · 1.02 KB
/
tree_print.py
File metadata and controls
executable file
·34 lines (28 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import os
import os.path
def showdir(path, depth, f):
for item in os.listdir(path):
if item == '.idea' or item == 'tree.txt' or item == '__pycache__' or item == '__init__.py':
continue
# print('item = ', item)
if "." not in item:
print(" " * depth + "+ " + item)
f.write(" " * depth + "+ " + item + "\n")
else:
print(" " * depth + "" + item)
f.write(" " * depth + "" + item + "\n")
newitem = path + '/' + item
if os.path.isdir(newitem):
showdir(newitem, depth + 1, f)
def showmultidir():
# current_path = os.path.abspath(__file__)
current_dir = os.path.dirname(os.path.abspath(__file__))
# print(current_path)
# print(current_dir)
# current_dir = "E:\Python\PyCode\RL_Algorithm_V2_0\RL_Algorithm"
# f = open(current_dir + "\\" + "tree.txt", "w")
f = open("tree.txt", "w")
showdir(path=current_dir, depth=0, f=f)
f.close()
if __name__ == '__main__':
showmultidir()