python递归目录子目录列出目录和文件

来源:互联网 发布:扫码查价软件 编辑:程序博客网 时间:2024/06/05 04:09
import osdef scandir(dir):    for f in os.listdir(dir):        _f = dir+'/'+f;        if os.path.isdir(_f):print _f            scandir(_f)        else:            if os.path.isfile(_f):print _f    passprint scandir("/root/img")




0 0
原创粉丝点击