macOS系统里如何遍历目录里的文件?

img


macOS系统里如何遍历目录里的文件?
os.walk()函数macOS用不了

怎么会,他这个也是mac吧
https://blog.csdn.net/qq_37344125/article/details/107972463

emmm...
您这图片里显示os.walk()函数运行成功...
如果要查看walk对象的具体参数,要把它们循环赋值出来。

import os
path=''
content=os.walk(path)
count=0
for root,dirs,files in content:
    count+=1
    print(f'第{count}个可识别目录',root,dirs,files,sep='\n',end='\n\n')

温馨提示:记得把path填上。