标签:users import print file os.path 内容 div join 打开文件
import os
filePath = "/Users/busensei/wzy/filePath/"
def read(filePath, n):
it = os.listdir(filePath) # 打开文件夹
for el in it:
# 拿到路径
fp = os.path.join(filePath, el) # 获取到绝对路径
if os.path.isdir(fp): # 判断是否是文件夹
print("\t" * n, el)
read(fp, n + 1) # 又是文件夹. 继续读取内部的内容 递归入口
else:
print("\t" * n, el) # 递归出口
read(filePath, 0)
标签:users import print file os.path 内容 div join 打开文件
原文地址:https://www.cnblogs.com/xiao-xue-di/p/9454976.html