python 删除空文件夹脚本

#coding:utf-8
import os
for root,dirs,files in os.walk("D:\\"):
    if dirs == [] and files ==[]:
        os.system('rd /S /Q %s' %root) 

用walk()遍历文件夹,判断

if dirs == [] and files ==[]:
       

然后调用shell命令删除文件夹!

posted @ 2012-01-22 09:42  cacique  阅读(1004)  评论(0编辑  收藏  举报
Copyright ©2011 Goodspeed Cheng