清理目录下的空文件夹
#encoding:utf-8
import os
import sys
def delete_empty(path):
while True:
emp = []
for root, dirs, files in os.walk(path):
if dirs.__len__() == 0 and files.__len__() == 0 and root != path:
emp.append(root)
if emp.__len__() == 0:
break
else:
for _ in emp:
if os.path.exists(_):
os.rmdir(_)
emp.remove(_)
img='J:/TF6/data-old/'
delete_empty(img)