forked from souravjain540/Basic-Python-Programs
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdirTree.py
More file actions
Latest commit
29 lines (26 loc) · 667 Bytes
/
Copy pathdirTree.py
File metadata and controls
29 lines (26 loc) · 667 Bytes
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
importos
importos.path
frompathlibimportPath
defdisplay(path, level=0):
try :
path=Path(path)
except:
print("Enter right path")
return
k=os.listdir(path)
foriink:
ifos.path.isfile(os.path.join(path, i)):
print(" "*level, "--F--", i)
elifos.path.isdir(os.path.join(path, i)):
print(" "*level, "+-D--", i)
display(os.path.join(path, i), level=level+1)
else:
print(i)
return
if__name__=="__main__":
print("Enter a path")
s=input()
ifs=="" :
s=os.getcwd()
l=0
display(s, level=0)