import os
def dirf(path,depth = 0):
path = os.path.abspath(path)
files=os.listdir(path)
for f in files:
print(’ '2depth,f)
f = os.path.join(path,f)
if os.path.isdir(f):
dirf(f,depth +=1)
来自七月在线课程:https://www.julyedu.com/course/getDetail/130/1qr54GS0WPKCHeT8ePifXzLG
os.getcwd():获取当前目录