python-文件遍历
# 遍历当前目录下所有文件
def read_file(path):
if os.path.isdir(path):
file_dirs = os.listdir(path)
for file_dir in file_dirs:
if os.path.isdir(os.path.join(path, file_dir)):
read_file(os.path.join(path, file_dir))
else:
print(os.path.join(path, file_dir))
else:
print(path)
read_file(os.getcwd())