Python 遍历目录下的子目录和文件

import os

A: 遍历目录下的子目录和文件

for root,dirs ,files in os.walk(path)

root:要访问的路径名

dirs:遍历目录下的子目录

files:遍历目录下的文件

B: 遍历目录下所有文件

os.listdir(path)

猜你喜欢

转载自www.cnblogs.com/shuangcao/p/11315955.html