大家好,我是胡亥大魔王。今天介绍python中遍历目录树
假如你想对某个文件夹中的所有文件改名,包括该文件夹中所有子文件夹中的所有文件。也就是说,你想遍历整个目录树,python提供了一个 os.walk
函数,可以完成这件事
import os
for folderName, subfolders, filenames in os.walk('D:\\python_learn'):
print('The current folder i
大家好,我是胡亥大魔王。今天介绍python中遍历目录树
假如你想对某个文件夹中的所有文件改名,包括该文件夹中所有子文件夹中的所有文件。也就是说,你想遍历整个目录树,python提供了一个 os.walk
函数,可以完成这件事
import os
for folderName, subfolders, filenames in os.walk('D:\\python_learn'):
print('The current folder i